make index frameset work again.

master
Rémi Cocula 8 years ago
parent a51389a8d7
commit 78022e34c3
  1. 98
      libresonic-main/src/main/java/org/libresonic/player/controller/HomeController.java
  2. 78
      libresonic-main/src/main/java/org/libresonic/player/controller/LeftController.java
  3. 40
      libresonic-main/src/main/java/org/libresonic/player/controller/NowPlayingController.java
  4. 34
      libresonic-main/src/main/java/org/libresonic/player/controller/PlayQueueController.java
  5. 46
      libresonic-main/src/main/java/org/libresonic/player/controller/RightController.java
  6. 43
      libresonic-main/src/main/java/org/libresonic/player/controller/TopController.java
  7. 5
      libresonic-main/src/main/resources/applicationContext-security.xml
  8. 49
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -19,35 +19,18 @@
*/ */
package org.libresonic.player.controller; package org.libresonic.player.controller;
import java.io.IOException; import org.libresonic.player.domain.*;
import java.util.ArrayList; import org.libresonic.player.service.*;
import java.util.Calendar; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collections; import org.springframework.stereotype.Controller;
import java.util.Date; import org.springframework.web.bind.annotation.RequestMapping;
import java.util.HashMap; import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.view.RedirectView; import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.AlbumListType; import javax.servlet.http.HttpServletRequest;
import org.libresonic.player.domain.CoverArtScheme; import java.io.IOException;
import org.libresonic.player.domain.Genre; import java.util.*;
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.service.MediaFileService;
import org.libresonic.player.service.MediaScannerService;
import org.libresonic.player.service.RatingService;
import org.libresonic.player.service.SearchService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import static org.springframework.web.bind.ServletRequestUtils.getIntParameter; import static org.springframework.web.bind.ServletRequestUtils.getIntParameter;
import static org.springframework.web.bind.ServletRequestUtils.getStringParameter; import static org.springframework.web.bind.ServletRequestUtils.getStringParameter;
@ -57,18 +40,27 @@ import static org.springframework.web.bind.ServletRequestUtils.getStringParamete
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class HomeController extends ParameterizableViewController { @Controller
@RequestMapping("/home")
public class HomeController {
private static final int LIST_SIZE = 40; private static final int LIST_SIZE = 40;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private MediaScannerService mediaScannerService; private MediaScannerService mediaScannerService;
@Autowired
private RatingService ratingService; private RatingService ratingService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@Autowired
private SearchService searchService; private SearchService searchService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
User user = securityService.getCurrentUser(request); User user = securityService.getCurrentUser(request);
if (user.isAdminRole() && settingsService.isGettingStartedEnabled()) { if (user.isAdminRole() && settingsService.isGettingStartedEnabled()) {
@ -85,7 +77,7 @@ public class HomeController extends ParameterizableViewController {
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(user.getUsername(), List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(user.getUsername(),
selectedMusicFolder == null ? null : selectedMusicFolder.getId()); selectedMusicFolder == null ? null : selectedMusicFolder.getId());
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
List<Album> albums = Collections.emptyList(); List<Album> albums = Collections.emptyList();
switch (listType) { switch (listType) {
case HIGHEST: case HIGHEST:
@ -142,13 +134,11 @@ public class HomeController extends ParameterizableViewController {
map.put("musicFolder", selectedMusicFolder); map.put("musicFolder", selectedMusicFolder);
map.put("listReloadDelay", userSettings.getListReloadDelay()); map.put("listReloadDelay", userSettings.getListReloadDelay());
ModelAndView result = super.handleRequestInternal(request, response); return new ModelAndView("home","model",map);
result.addObject("model", map);
return result;
} }
private List<Album> getHighestRated(int offset, int count, List<MusicFolder> musicFolders) { private List<Album> getHighestRated(int offset, int count, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile mediaFile : ratingService.getHighestRatedAlbums(offset, count, musicFolders)) { for (MediaFile mediaFile : ratingService.getHighestRatedAlbums(offset, count, musicFolders)) {
Album album = createAlbum(mediaFile); Album album = createAlbum(mediaFile);
album.setRating((int) Math.round(ratingService.getAverageRating(mediaFile) * 10.0D)); album.setRating((int) Math.round(ratingService.getAverageRating(mediaFile) * 10.0D));
@ -158,7 +148,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getMostFrequent(int offset, int count, List<MusicFolder> musicFolders) { private List<Album> getMostFrequent(int offset, int count, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile mediaFile : mediaFileService.getMostFrequentlyPlayedAlbums(offset, count, musicFolders)) { for (MediaFile mediaFile : mediaFileService.getMostFrequentlyPlayedAlbums(offset, count, musicFolders)) {
Album album = createAlbum(mediaFile); Album album = createAlbum(mediaFile);
album.setPlayCount(mediaFile.getPlayCount()); album.setPlayCount(mediaFile.getPlayCount());
@ -168,7 +158,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getMostRecent(int offset, int count, List<MusicFolder> musicFolders) { private List<Album> getMostRecent(int offset, int count, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile mediaFile : mediaFileService.getMostRecentlyPlayedAlbums(offset, count, musicFolders)) { for (MediaFile mediaFile : mediaFileService.getMostRecentlyPlayedAlbums(offset, count, musicFolders)) {
Album album = createAlbum(mediaFile); Album album = createAlbum(mediaFile);
album.setLastPlayed(mediaFile.getLastPlayed()); album.setLastPlayed(mediaFile.getLastPlayed());
@ -178,7 +168,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getNewest(int offset, int count, List<MusicFolder> musicFolders) throws IOException { private List<Album> getNewest(int offset, int count, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getNewestAlbums(offset, count, musicFolders)) { for (MediaFile file : mediaFileService.getNewestAlbums(offset, count, musicFolders)) {
Album album = createAlbum(file); Album album = createAlbum(file);
Date created = file.getCreated(); Date created = file.getCreated();
@ -192,7 +182,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getStarred(int offset, int count, String username, List<MusicFolder> musicFolders) throws IOException { private List<Album> getStarred(int offset, int count, String username, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getStarredAlbums(offset, count, username, musicFolders)) { for (MediaFile file : mediaFileService.getStarredAlbums(offset, count, username, musicFolders)) {
result.add(createAlbum(file)); result.add(createAlbum(file));
} }
@ -200,7 +190,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getRandom(int count, List<MusicFolder> musicFolders) throws IOException { private List<Album> getRandom(int count, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile file : searchService.getRandomAlbums(count, musicFolders)) { for (MediaFile file : searchService.getRandomAlbums(count, musicFolders)) {
result.add(createAlbum(file)); result.add(createAlbum(file));
} }
@ -208,7 +198,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getAlphabetical(int offset, int count, boolean byArtist, List<MusicFolder> musicFolders) throws IOException { private List<Album> getAlphabetical(int offset, int count, boolean byArtist, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getAlphabeticalAlbums(offset, count, byArtist, musicFolders)) { for (MediaFile file : mediaFileService.getAlphabeticalAlbums(offset, count, byArtist, musicFolders)) {
result.add(createAlbum(file)); result.add(createAlbum(file));
} }
@ -216,7 +206,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getByYear(int offset, int count, int fromYear, int toYear, List<MusicFolder> musicFolders) { private List<Album> getByYear(int offset, int count, int fromYear, int toYear, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getAlbumsByYear(offset, count, fromYear, toYear, musicFolders)) { for (MediaFile file : mediaFileService.getAlbumsByYear(offset, count, fromYear, toYear, musicFolders)) {
Album album = createAlbum(file); Album album = createAlbum(file);
album.setYear(file.getYear()); album.setYear(file.getYear());
@ -226,7 +216,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Integer> createDecades() { private List<Integer> createDecades() {
List<Integer> result = new ArrayList<Integer>(); List<Integer> result = new ArrayList<>();
int decade = Calendar.getInstance().get(Calendar.YEAR) / 10; int decade = Calendar.getInstance().get(Calendar.YEAR) / 10;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
result.add((decade - i) * 10); result.add((decade - i) * 10);
@ -235,7 +225,7 @@ public class HomeController extends ParameterizableViewController {
} }
private List<Album> getByGenre(int offset, int count, String genre, List<MusicFolder> musicFolders) { private List<Album> getByGenre(int offset, int count, String genre, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>(); List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getAlbumsByGenre(offset, count, genre, musicFolders)) { for (MediaFile file : mediaFileService.getAlbumsByGenre(offset, count, genre, musicFolders)) {
result.add(createAlbum(file)); result.add(createAlbum(file));
} }
@ -252,30 +242,6 @@ public class HomeController extends ParameterizableViewController {
return album; return album;
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setMediaScannerService(MediaScannerService mediaScannerService) {
this.mediaScannerService = mediaScannerService;
}
public void setRatingService(RatingService ratingService) {
this.ratingService = ratingService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
/** /**
* Contains info for a single album. * Contains info for a single album.
*/ */

@ -19,41 +19,31 @@
*/ */
package org.libresonic.player.controller; package org.libresonic.player.controller;
import java.io.File; import org.libresonic.player.domain.*;
import java.util.Arrays; import org.libresonic.player.service.*;
import java.util.Calendar; import org.libresonic.player.util.FileUtil;
import java.util.HashMap; import org.libresonic.player.util.StringUtil;
import java.util.List; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Locale; import org.springframework.stereotype.Controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.ParameterizableViewController;
import org.springframework.web.servlet.support.RequestContextUtils; import org.springframework.web.servlet.support.RequestContextUtils;
import org.libresonic.player.domain.InternetRadio; import javax.servlet.http.HttpServletRequest;
import org.libresonic.player.domain.MediaLibraryStatistics; import javax.servlet.http.HttpServletResponse;
import org.libresonic.player.domain.MusicFolder; import java.io.File;
import org.libresonic.player.domain.MusicFolderContent; import java.util.*;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.MediaScannerService;
import org.libresonic.player.service.MusicIndexService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.FileUtil;
import org.libresonic.player.util.StringUtil;
/** /**
* Controller for the left index frame. * Controller for the left index frame.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class LeftController extends ParameterizableViewController { @Controller
@RequestMapping("/left")
public class LeftController {
// Update this time if you want to force a refresh in clients. // Update this time if you want to force a refresh in clients.
private static final Calendar LAST_COMPATIBILITY_TIME = Calendar.getInstance(); private static final Calendar LAST_COMPATIBILITY_TIME = Calendar.getInstance();
@ -62,17 +52,22 @@ public class LeftController extends ParameterizableViewController {
LAST_COMPATIBILITY_TIME.set(Calendar.MILLISECOND, 0); LAST_COMPATIBILITY_TIME.set(Calendar.MILLISECOND, 0);
} }
@Autowired
private MediaScannerService mediaScannerService; private MediaScannerService mediaScannerService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private MusicIndexService musicIndexService; private MusicIndexService musicIndexService;
@Autowired
private PlayerService playerService; private PlayerService playerService;
/** /**
* Note: This class intentionally does not implement org.springframework.web.servlet.mvc.LastModified * Note: This class intentionally does not implement org.springframework.web.servlet.mvc.LastModified
* as we don't need browser-side caching of left.jsp. This method is only used by RESTController. * as we don't need browser-side caching of left.jsp. This method is only used by RESTController.
*/ */
public long getLastModified(HttpServletRequest request) { long getLastModified(HttpServletRequest request) {
saveSelectedMusicFolder(request); saveSelectedMusicFolder(request);
if (mediaScannerService.isScanning()) { if (mediaScannerService.isScanning()) {
@ -115,10 +110,10 @@ public class LeftController extends ParameterizableViewController {
return lastModified; return lastModified;
} }
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
boolean musicFolderChanged = saveSelectedMusicFolder(request); boolean musicFolderChanged = saveSelectedMusicFolder(request);
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
MediaLibraryStatistics statistics = mediaScannerService.getStatistics(); MediaLibraryStatistics statistics = mediaScannerService.getStatistics();
Locale locale = RequestContextUtils.getLocale(request); Locale locale = RequestContextUtils.getLocale(request);
@ -131,7 +126,7 @@ public class LeftController extends ParameterizableViewController {
String username = securityService.getCurrentUsername(request); String username = securityService.getCurrentUsername(request);
List<MusicFolder> allMusicFolders = settingsService.getMusicFoldersForUser(username); List<MusicFolder> allMusicFolders = settingsService.getMusicFoldersForUser(username);
MusicFolder selectedMusicFolder = settingsService.getSelectedMusicFolder(username); MusicFolder selectedMusicFolder = settingsService.getSelectedMusicFolder(username);
List<MusicFolder> musicFoldersToUse = selectedMusicFolder == null ? allMusicFolders : Arrays.asList(selectedMusicFolder); List<MusicFolder> musicFoldersToUse = selectedMusicFolder == null ? allMusicFolders : Collections.singletonList(selectedMusicFolder);
UserSettings userSettings = settingsService.getUserSettings(username); UserSettings userSettings = settingsService.getUserSettings(username);
MusicFolderContent musicFolderContent = musicIndexService.getMusicFolderContent(musicFoldersToUse, refresh); MusicFolderContent musicFolderContent = musicIndexService.getMusicFolderContent(musicFoldersToUse, refresh);
@ -158,9 +153,7 @@ public class LeftController extends ParameterizableViewController {
map.put("indexes", musicFolderContent.getIndexedArtists().keySet()); map.put("indexes", musicFolderContent.getIndexedArtists().keySet());
map.put("user", securityService.getCurrentUser(request)); map.put("user", securityService.getCurrentUser(request));
ModelAndView result = super.handleRequestInternal(request, response); return new ModelAndView("left","model",map);
result.addObject("model", map);
return result;
} }
private boolean saveSelectedMusicFolder(HttpServletRequest request) { private boolean saveSelectedMusicFolder(HttpServletRequest request) {
@ -177,25 +170,4 @@ public class LeftController extends ParameterizableViewController {
return true; return true;
} }
public void setMediaScannerService(MediaScannerService mediaScannerService) {
this.mediaScannerService = mediaScannerService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setMusicIndexService(MusicIndexService musicIndexService) {
this.musicIndexService = musicIndexService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
} }

@ -19,34 +19,40 @@
*/ */
package org.libresonic.player.controller; package org.libresonic.player.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.MediaFile; import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.Player; import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.TransferStatus; import org.libresonic.player.domain.TransferStatus;
import org.libresonic.player.service.MediaFileService; import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService; import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.StatusService; import org.libresonic.player.service.StatusService;
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.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* Controller for showing what's currently playing. * Controller for showing what's currently playing.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class NowPlayingController extends AbstractController { @Controller
@RequestMapping("/nowPlaying")
public class NowPlayingController {
@Autowired
private PlayerService playerService; private PlayerService playerService;
@Autowired
private StatusService statusService; private StatusService statusService;
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Player player = playerService.getPlayer(request, response); Player player = playerService.getPlayer(request, response);
@ -64,16 +70,4 @@ public class NowPlayingController extends AbstractController {
return new ModelAndView(new RedirectView(url)); return new ModelAndView(new RedirectView(url));
} }
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
} }

@ -19,41 +19,47 @@
*/ */
package org.libresonic.player.controller; 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.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.libresonic.player.domain.Player; import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.User; import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings; import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.PlayerService; import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService; import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService; 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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/** /**
* Controller for the playlist frame. * Controller for the playlist frame.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class PlayQueueController extends ParameterizableViewController { @Controller
@RequestMapping("/playQueue")
public class PlayQueueController {
@Autowired
private PlayerService playerService; private PlayerService playerService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request); User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername()); UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
Player player = playerService.getPlayer(request, response); Player player = playerService.getPlayer(request, response);
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("user", user); map.put("user", user);
map.put("player", player); map.put("player", player);
map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null)); map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null));
@ -62,9 +68,7 @@ public class PlayQueueController extends ParameterizableViewController {
map.put("notify", userSettings.isSongNotificationEnabled()); map.put("notify", userSettings.isSongNotificationEnabled());
map.put("autoHide", userSettings.isAutoHidePlayQueue()); map.put("autoHide", userSettings.isAutoHidePlayQueue());
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
ModelAndView result = super.handleRequestInternal(request, response); return new ModelAndView("playQueue","model",map);
result.addObject("model", map);
return result;
} }
public void setPlayerService(PlayerService playerService) { public void setPlayerService(PlayerService playerService) {

@ -19,35 +19,40 @@
*/ */
package org.libresonic.player.controller; 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.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.libresonic.player.domain.UserSettings; import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.SecurityService; import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.VersionService; import org.libresonic.player.service.VersionService;
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 javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/** /**
* Controller for the right frame. * Controller for the right frame.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class RightController extends ParameterizableViewController { @Controller
@RequestMapping("/right")
public class RightController {
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private VersionService versionService; private VersionService versionService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
ModelAndView result = super.handleRequestInternal(request, response); ModelAndView result = new ModelAndView("right");
UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request)); UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));
if (userSettings.isFinalVersionNotificationEnabled() && versionService.isNewFinalVersionAvailable()) { if (userSettings.isFinalVersionNotificationEnabled() && versionService.isNewFinalVersionAvailable()) {
@ -69,15 +74,4 @@ public class RightController extends ParameterizableViewController {
return result; return result;
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setVersionService(VersionService versionService) {
this.versionService = versionService;
}
} }

@ -19,33 +19,39 @@
*/ */
package org.libresonic.player.controller; 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.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.libresonic.player.domain.AvatarScheme; import org.libresonic.player.domain.AvatarScheme;
import org.libresonic.player.domain.User; import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings; import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.SecurityService; import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService; 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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/** /**
* Controller for the top frame. * Controller for the top frame.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class TopController extends ParameterizableViewController { @Controller
@RequestMapping("/top")
public class TopController {
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { @RequestMapping(method = RequestMethod.GET)
Map<String, Object> map = new HashMap<String, Object>(); protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request); User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername()); UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
@ -53,17 +59,6 @@ public class TopController extends ParameterizableViewController {
map.put("user", user); map.put("user", user);
map.put("showSideBar", userSettings.isShowSideBar()); map.put("showSideBar", userSettings.isShowSideBar());
map.put("showAvatar", userSettings.getAvatarScheme() != AvatarScheme.NONE); map.put("showAvatar", userSettings.getAvatarScheme() != AvatarScheme.NONE);
return new ModelAndView("top","model", map);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
} }
} }

@ -8,6 +8,11 @@
http://www.springframework.org/schema/security/spring-security-4.1.xsd"> http://www.springframework.org/schema/security/spring-security-4.1.xsd">
<security:http auto-config='true'> <security:http auto-config='true'>
<security:headers>
<security:frame-options policy="SAMEORIGIN"/>
</security:headers>
<!-- permitAll --> <!-- permitAll -->
<security:intercept-url pattern="/login.*" access="permitAll"/> <security:intercept-url pattern="/login.*" access="permitAll"/>
<security:intercept-url pattern="/recover.view" access="permitAll" /> <security:intercept-url pattern="/recover.view" access="permitAll" />

@ -15,20 +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="leftController" class="org.libresonic.player.controller.LeftController">
<property name="viewName" value="left"/>
<property name="mediaScannerService" ref="mediaScannerService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="musicIndexService" ref="musicIndexService"/>
<property name="playerService" ref="playerService"/>
</bean>
<bean id="rightController" class="org.libresonic.player.controller.RightController">
<property name="viewName" value="right"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="versionService" ref="versionService"/>
</bean>
<bean id="statusController" class="org.libresonic.player.controller.StatusController"> <bean id="statusController" class="org.libresonic.player.controller.StatusController">
<property name="viewName" value="status"/> <property name="viewName" value="status"/>
<property name="statusService" ref="statusService"/> <property name="statusService" ref="statusService"/>
@ -58,11 +44,6 @@
<property name="securityService" ref="securityService"/> <property name="securityService" ref="securityService"/>
<property name="playlistService" ref="playlistService"/> <property name="playlistService" ref="playlistService"/>
</bean> </bean>
<bean id="topController" class="org.libresonic.player.controller.TopController">
<property name="viewName" value="top"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="helpController" class="org.libresonic.player.controller.HelpController"> <bean id="helpController" class="org.libresonic.player.controller.HelpController">
<property name="viewName" value="help"/> <property name="viewName" value="help"/>
<property name="versionService" ref="versionService"/> <property name="versionService" ref="versionService"/>
@ -148,11 +129,6 @@
<property name="viewName" value="changeCoverArt"/> <property name="viewName" value="changeCoverArt"/>
<property name="mediaFileService" ref="mediaFileService"/> <property name="mediaFileService" ref="mediaFileService"/>
</bean> </bean>
<bean id="nowPlayingController" class="org.libresonic.player.controller.NowPlayingController">
<property name="playerService" ref="playerService"/>
<property name="statusService" ref="statusService"/>
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="starredController" class="org.libresonic.player.controller.StarredController"> <bean id="starredController" class="org.libresonic.player.controller.StarredController">
<property name="viewName" value="starred"/> <property name="viewName" value="starred"/>
<property name="playerService" ref="playerService"/> <property name="playerService" ref="playerService"/>
@ -196,26 +172,11 @@
<property name="settingsService" ref="settingsService"/> <property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/> <property name="securityService" ref="securityService"/>
</bean> </bean>
<bean id="homeController" class="org.libresonic.player.controller.HomeController">
<property name="viewName" value="home"/>
<property name="ratingService" ref="ratingService"/>
<property name="mediaScannerService" ref="mediaScannerService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="searchService" ref="searchService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="editTagsController" class="org.libresonic.player.controller.EditTagsController"> <bean id="editTagsController" class="org.libresonic.player.controller.EditTagsController">
<property name="viewName" value="editTags"/> <property name="viewName" value="editTags"/>
<property name="mediaFileService" ref="mediaFileService"/> <property name="mediaFileService" ref="mediaFileService"/>
<property name="metaDataParserFactory" ref="metaDataParserFactory"/> <property name="metaDataParserFactory" ref="metaDataParserFactory"/>
</bean> </bean>
<bean id="playQueueController" class="org.libresonic.player.controller.PlayQueueController">
<property name="viewName" value="playQueue"/>
<property name="playerService" ref="playerService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="coverArtController" class="org.libresonic.player.controller.CoverArtController" init-method="init"> <bean id="coverArtController" class="org.libresonic.player.controller.CoverArtController" init-method="init">
<property name="mediaFileService" ref="mediaFileService"/> <property name="mediaFileService" ref="mediaFileService"/>
<property name="transcodingService" ref="transcodingService"/> <property name="transcodingService" ref="transcodingService"/>
@ -338,8 +299,6 @@
<prop key="/playlists.view">playlistsController</prop> <prop key="/playlists.view">playlistsController</prop>
<prop key="/help.view">helpController</prop> <prop key="/help.view">helpController</prop>
<prop key="/lyrics.view">lyricsController</prop> <prop key="/lyrics.view">lyricsController</prop>
<prop key="/left.view">leftController</prop>
<prop key="/right.view">rightController</prop>
<prop key="/status.view">statusController</prop> <prop key="/status.view">statusController</prop>
<prop key="/more.view">moreController</prop> <prop key="/more.view">moreController</prop>
<prop key="/upload.view">uploadController</prop> <prop key="/upload.view">uploadController</prop>
@ -348,20 +307,14 @@
<prop key="/setMusicFileInfo.view">setMusicFileInfoController</prop> <prop key="/setMusicFileInfo.view">setMusicFileInfoController</prop>
<prop key="/createShare.view">shareManagementController</prop> <prop key="/createShare.view">shareManagementController</prop>
<prop key="/setRating.view">setRatingController</prop> <prop key="/setRating.view">setRatingController</prop>
<prop key="/top.view">topController</prop>
<prop key="/randomPlayQueue.view">randomPlayQueueController</prop> <prop key="/randomPlayQueue.view">randomPlayQueueController</prop>
<prop key="/changeCoverArt.view">changeCoverArtController</prop> <prop key="/changeCoverArt.view">changeCoverArtController</prop>
<!--
login.view has moved to the LoginController
<prop key="/login.view">multiController</prop>
-->
<prop key="/recover.view">multiController</prop> <prop key="/recover.view">multiController</prop>
<prop key="/accessDenied.view">multiController</prop> <prop key="/accessDenied.view">multiController</prop>
<prop key="/notFound.view">multiController</prop> <prop key="/notFound.view">multiController</prop>
<prop key="/gettingStarted.view">multiController</prop> <prop key="/gettingStarted.view">multiController</prop>
<prop key="/index.view">multiController</prop> <prop key="/index.view">multiController</prop>
<prop key="/videoPlayer.view">videoPlayerController</prop> <prop key="/videoPlayer.view">videoPlayerController</prop>
<prop key="/nowPlaying.view">nowPlayingController</prop>
<prop key="/starred.view">starredController</prop> <prop key="/starred.view">starredController</prop>
<prop key="/settings.view">settingsController</prop> <prop key="/settings.view">settingsController</prop>
<prop key="/dlnaSettings.view">dlnaSettingsController</prop> <prop key="/dlnaSettings.view">dlnaSettingsController</prop>
@ -371,9 +324,7 @@
<prop key="/internetRadioSettings.view">internetRadioSettingsController</prop> <prop key="/internetRadioSettings.view">internetRadioSettingsController</prop>
<prop key="/avatarUpload.view">avatarUploadController</prop> <prop key="/avatarUpload.view">avatarUploadController</prop>
<prop key="/allmusic.view">allmusicController</prop> <prop key="/allmusic.view">allmusicController</prop>
<prop key="/home.view">homeController</prop>
<prop key="/editTags.view">editTagsController</prop> <prop key="/editTags.view">editTagsController</prop>
<prop key="/playQueue.view">playQueueController</prop>
<prop key="/coverArt.view">coverArtController</prop> <prop key="/coverArt.view">coverArtController</prop>
<prop key="/avatar.view">avatarController</prop> <prop key="/avatar.view">avatarController</prop>
<prop key="/proxy.view">proxyController</prop> <prop key="/proxy.view">proxyController</prop>

Loading…
Cancel
Save