From 70ed378ae09763b7134adae265589f3bd183cbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cocula?= Date: Sun, 18 Dec 2016 00:12:16 +0100 Subject: [PATCH] Controllers migration. --- .../controller/ShareManagementController.java | 54 ++++++------------- .../src/main/resources/libresonic-servlet.xml | 9 ---- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/ShareManagementController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/ShareManagementController.java index f1bab574..aad11bdd 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/ShareManagementController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/ShareManagementController.java @@ -23,39 +23,42 @@ import org.libresonic.player.domain.MediaFile; import org.libresonic.player.domain.PlayQueue; import org.libresonic.player.domain.Player; import org.libresonic.player.domain.Share; -import org.libresonic.player.service.MediaFileService; -import org.libresonic.player.service.PlayerService; -import org.libresonic.player.service.PlaylistService; -import org.libresonic.player.service.SecurityService; -import org.libresonic.player.service.SettingsService; -import org.libresonic.player.service.ShareService; +import org.libresonic.player.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.ServletRequestBindingException; 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.multiaction.MultiActionController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Controller for sharing music on Twitter, Facebook etc. * * @author Sindre Mehus */ -public class ShareManagementController extends MultiActionController { +@Controller +@RequestMapping("/createShare") +public class ShareManagementController { + @Autowired private MediaFileService mediaFileService; + @Autowired private SettingsService settingsService; + @Autowired private ShareService shareService; + @Autowired private PlayerService playerService; + @Autowired private PlaylistService playlistService; + @Autowired private SecurityService securityService; + @RequestMapping(method = RequestMethod.GET) public ModelAndView createShare(HttpServletRequest request, HttpServletResponse response) throws Exception { List files = getMediaFiles(request); @@ -95,7 +98,7 @@ public class ShareManagementController extends MultiActionController { String playerId = request.getParameter("player"); Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist"); - List result = new ArrayList(); + List result = new ArrayList<>(); if (id != null) { MediaFile album = mediaFileService.getMediaFile(id); @@ -122,27 +125,4 @@ public class ShareManagementController extends MultiActionController { 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; - } } \ No newline at end of file diff --git a/libresonic-main/src/main/resources/libresonic-servlet.xml b/libresonic-main/src/main/resources/libresonic-servlet.xml index d8692963..f26e2ccd 100644 --- a/libresonic-main/src/main/resources/libresonic-servlet.xml +++ b/libresonic-main/src/main/resources/libresonic-servlet.xml @@ -15,14 +15,6 @@ - - - - - - - - @@ -186,7 +178,6 @@ multiController - shareManagementController setRatingController changeCoverArtController multiController