Controllers migration.

master
Rémi Cocula 8 years ago
parent f90de5e310
commit 70ed378ae0
  1. 54
      libresonic-main/src/main/java/org/libresonic/player/controller/ShareManagementController.java
  2. 9
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -23,39 +23,42 @@ import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.PlayQueue; import org.libresonic.player.domain.PlayQueue;
import org.libresonic.player.domain.Player; import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.Share; import org.libresonic.player.domain.Share;
import org.libresonic.player.service.MediaFileService; import org.libresonic.player.service.*;
import org.libresonic.player.service.PlayerService; import org.springframework.beans.factory.annotation.Autowired;
import org.libresonic.player.service.PlaylistService; import org.springframework.stereotype.Controller;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.ShareService;
import org.springframework.web.bind.ServletRequestBindingException; import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.ServletRequestUtils; 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.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Controller for sharing music on Twitter, Facebook etc. * Controller for sharing music on Twitter, Facebook etc.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class ShareManagementController extends MultiActionController { @Controller
@RequestMapping("/createShare")
public class ShareManagementController {
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private ShareService shareService; private ShareService shareService;
@Autowired
private PlayerService playerService; private PlayerService playerService;
@Autowired
private PlaylistService playlistService; private PlaylistService playlistService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView createShare(HttpServletRequest request, HttpServletResponse response) throws Exception { public ModelAndView createShare(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<MediaFile> files = getMediaFiles(request); List<MediaFile> files = getMediaFiles(request);
@ -95,7 +98,7 @@ public class ShareManagementController extends MultiActionController {
String playerId = request.getParameter("player"); String playerId = request.getParameter("player");
Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist"); Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
List<MediaFile> result = new ArrayList<MediaFile>(); List<MediaFile> result = new ArrayList<>();
if (id != null) { if (id != null) {
MediaFile album = mediaFileService.getMediaFile(id); MediaFile album = mediaFileService.getMediaFile(id);
@ -122,27 +125,4 @@ public class ShareManagementController extends MultiActionController {
return result; return result;
} }
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setShareService(ShareService shareService) {
this.shareService = shareService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
} }

@ -15,14 +15,6 @@
<mvc:annotation-driven /> <mvc:annotation-driven />
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/> <context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/>
<bean id="shareManagementController" class="org.libresonic.player.controller.ShareManagementController">
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="shareService" ref="shareService"/>
<property name="playerService" ref="playerService"/>
<property name="playlistService" ref="playlistService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="setRatingController" class="org.libresonic.player.controller.SetRatingController"> <bean id="setRatingController" class="org.libresonic.player.controller.SetRatingController">
<property name="ratingService" ref="ratingService"/> <property name="ratingService" ref="ratingService"/>
<property name="mediaFileService" ref="mediaFileService"/> <property name="mediaFileService" ref="mediaFileService"/>
@ -186,7 +178,6 @@
<property name="mappings"> <property name="mappings">
<props> <props>
<prop key="/exportPlaylist.view">multiController</prop> <prop key="/exportPlaylist.view">multiController</prop>
<prop key="/createShare.view">shareManagementController</prop>
<prop key="/setRating.view">setRatingController</prop> <prop key="/setRating.view">setRatingController</prop>
<prop key="/changeCoverArt.view">changeCoverArtController</prop> <prop key="/changeCoverArt.view">changeCoverArtController</prop>
<prop key="/recover.view">multiController</prop> <prop key="/recover.view">multiController</prop>

Loading…
Cancel
Save