Merge branch 'develop' into develop-nolicense-fixcoverart
Conflicts: libresonic-main/src/main/java/org/libresonic/player/command/NetworkSettingsCommand.java libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java
This commit is contained in:
@@ -38,6 +38,10 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
||||
-15
@@ -37,8 +37,6 @@ public class AdvancedSettingsCommand {
|
||||
private String ldapManagerPassword;
|
||||
private boolean ldapAutoShadowing;
|
||||
private String brand;
|
||||
private boolean isReloadNeeded;
|
||||
private boolean toast;
|
||||
|
||||
private String smtpServer;
|
||||
private String smtpEncryption;
|
||||
@@ -120,19 +118,6 @@ public class AdvancedSettingsCommand {
|
||||
}
|
||||
|
||||
public void setReloadNeeded(boolean reloadNeeded) {
|
||||
isReloadNeeded = reloadNeeded;
|
||||
}
|
||||
|
||||
public boolean isReloadNeeded() {
|
||||
return isReloadNeeded;
|
||||
}
|
||||
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
|
||||
public void setToast(boolean toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
|
||||
public String getSmtpServer() {
|
||||
|
||||
-14
@@ -46,8 +46,6 @@ public class GeneralSettingsCommand {
|
||||
private String[] locales;
|
||||
private String themeIndex;
|
||||
private Theme[] themes;
|
||||
private boolean isReloadNeeded;
|
||||
private boolean toast;
|
||||
|
||||
public String getPlaylistFolder() {
|
||||
return playlistFolder;
|
||||
@@ -169,12 +167,7 @@ public class GeneralSettingsCommand {
|
||||
this.themes = themes;
|
||||
}
|
||||
|
||||
public boolean isReloadNeeded() {
|
||||
return isReloadNeeded;
|
||||
}
|
||||
|
||||
public void setReloadNeeded(boolean reloadNeeded) {
|
||||
isReloadNeeded = reloadNeeded;
|
||||
}
|
||||
|
||||
public boolean isSortAlbumsByYear() {
|
||||
@@ -193,11 +186,4 @@ public class GeneralSettingsCommand {
|
||||
this.gettingStartedEnabled = gettingStartedEnabled;
|
||||
}
|
||||
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
|
||||
public void setToast(boolean toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
}
|
||||
|
||||
-9
@@ -41,7 +41,6 @@ public class MusicFolderSettingsCommand {
|
||||
private boolean organizeByFolderStructure;
|
||||
private List<MusicFolderInfo> musicFolders;
|
||||
private MusicFolderInfo newMusicFolder;
|
||||
private boolean reload;
|
||||
|
||||
public String getInterval() {
|
||||
return interval;
|
||||
@@ -91,14 +90,6 @@ public class MusicFolderSettingsCommand {
|
||||
this.newMusicFolder = newMusicFolder;
|
||||
}
|
||||
|
||||
public void setReload(boolean reload) {
|
||||
this.reload = reload;
|
||||
}
|
||||
|
||||
public boolean isReload() {
|
||||
return reload;
|
||||
}
|
||||
|
||||
public boolean isOrganizeByFolderStructure() {
|
||||
return organizeByFolderStructure;
|
||||
}
|
||||
|
||||
+4
-1
@@ -32,7 +32,9 @@ public class NetworkSettingsCommand {
|
||||
private String urlRedirectCustomUrl;
|
||||
private String urlRedirectType;
|
||||
private int port;
|
||||
<<<<<<< HEAD
|
||||
private boolean toast;
|
||||
=======
|
||||
|
||||
public void setPortForwardingEnabled(boolean portForwardingEnabled) {
|
||||
this.portForwardingEnabled = portForwardingEnabled;
|
||||
@@ -73,6 +75,7 @@ public class NetworkSettingsCommand {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
@@ -81,7 +84,7 @@ public class NetworkSettingsCommand {
|
||||
this.toast = toast;
|
||||
}
|
||||
|
||||
|
||||
=======
|
||||
public String getUrlRedirectType() {
|
||||
return urlRedirectType;
|
||||
}
|
||||
|
||||
-9
@@ -61,7 +61,6 @@ public class PersonalSettingsCommand {
|
||||
private int listReloadDelay;
|
||||
private String lastFmUsername;
|
||||
private String lastFmPassword;
|
||||
private boolean isReloadNeeded;
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
@@ -271,14 +270,6 @@ public class PersonalSettingsCommand {
|
||||
this.lastFmPassword = lastFmPassword;
|
||||
}
|
||||
|
||||
public boolean isReloadNeeded() {
|
||||
return isReloadNeeded;
|
||||
}
|
||||
|
||||
public void setReloadNeeded(boolean reloadNeeded) {
|
||||
isReloadNeeded = reloadNeeded;
|
||||
}
|
||||
|
||||
public boolean isQueueFollowingSongs() {
|
||||
return queueFollowingSongs;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public class PlayerSettingsCommand {
|
||||
private EnumHolder[] transcodeSchemeHolders;
|
||||
private Player[] players;
|
||||
private boolean isAdmin;
|
||||
private boolean isReloadNeeded;
|
||||
|
||||
public String getPlayerId() {
|
||||
return playerId;
|
||||
@@ -206,12 +205,8 @@ public class PlayerSettingsCommand {
|
||||
isAdmin = admin;
|
||||
}
|
||||
|
||||
public boolean isReloadNeeded() {
|
||||
return isReloadNeeded;
|
||||
}
|
||||
|
||||
public void setReloadNeeded(boolean reloadNeeded) {
|
||||
isReloadNeeded = reloadNeeded;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-8
@@ -32,7 +32,6 @@ public class PodcastSettingsCommand {
|
||||
private String folder;
|
||||
private String episodeRetentionCount;
|
||||
private String episodeDownloadCount;
|
||||
private boolean toast;
|
||||
|
||||
public String getInterval() {
|
||||
return interval;
|
||||
@@ -66,11 +65,4 @@ public class PodcastSettingsCommand {
|
||||
this.episodeDownloadCount = episodeDownloadCount;
|
||||
}
|
||||
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
|
||||
public void setToast(boolean toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-17
@@ -61,8 +61,6 @@ public class UserSettingsCommand {
|
||||
private EnumHolder[] transcodeSchemeHolders;
|
||||
private boolean transcodingSupported;
|
||||
private String transcodeDirectory;
|
||||
private boolean toast;
|
||||
private boolean reload;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
@@ -297,21 +295,7 @@ public class UserSettingsCommand {
|
||||
isSettingsRole = user != null && user.isSettingsRole();
|
||||
isShareRole = user != null && user.isShareRole();
|
||||
isLdapAuthenticated = user != null && user.isLdapAuthenticated();
|
||||
setNewUser(false);
|
||||
}
|
||||
|
||||
public void setToast(boolean toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
|
||||
public boolean isReload() {
|
||||
return reload;
|
||||
}
|
||||
|
||||
public void setReload(boolean reload) {
|
||||
this.reload = reload;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
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.support.RedirectAttributes;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate advanced settings.
|
||||
@@ -67,10 +68,10 @@ public class AdvancedSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute AdvancedSettingsCommand command,Model model) throws Exception {
|
||||
protected String doSubmitAction(@ModelAttribute AdvancedSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
command.setToast(true);
|
||||
command.setReloadNeeded(false);
|
||||
redirectAttributes.addFlashAttribute("settings_reload", false);
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
|
||||
try {
|
||||
settingsService.setDownloadBitrateLimit(Long.parseLong(command.getDownloadLimit()));
|
||||
@@ -99,8 +100,7 @@ public class AdvancedSettingsController {
|
||||
settingsService.setSmtpPassword(command.getSmtpPassword());
|
||||
}
|
||||
|
||||
model.addAttribute("command", command);
|
||||
return "advancedSettings";
|
||||
return "redirect:advancedSettings.view";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+23
-22
@@ -22,52 +22,51 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.libresonic.player.service.UPnPService;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate the UPnP/DLNA server settings.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class DLNASettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/dlnaSettings")
|
||||
public class DLNASettingsController {
|
||||
|
||||
@Autowired
|
||||
private UPnPService upnpService;
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String handleGet(Model model) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
if (isFormSubmission(request)) {
|
||||
handleParameters(request);
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("dlnaEnabled", settingsService.isDlnaEnabled());
|
||||
map.put("dlnaServerName", settingsService.getDlnaServerName());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
model.addAttribute("model", map);
|
||||
return "dlnaSettings";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given request represents a form submission.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @return if the request represents a form submission
|
||||
*/
|
||||
private boolean isFormSubmission(HttpServletRequest request) {
|
||||
return "POST".equals(request.getMethod());
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String handlePost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
||||
handleParameters(request);
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
return "redirect:dlnaSettings.view";
|
||||
}
|
||||
|
||||
private void handleParameters(HttpServletRequest request) {
|
||||
@@ -83,6 +82,7 @@ public class DLNASettingsController extends ParameterizableViewController {
|
||||
settingsService.save();
|
||||
upnpService.setMediaServerEnabled(dlnaEnabled);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
@@ -92,3 +92,4 @@ public class DLNASettingsController extends ParameterizableViewController {
|
||||
this.upnpService = upnpService;
|
||||
}
|
||||
}
|
||||
=======
|
||||
|
||||
+10
-7
@@ -28,6 +28,7 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class GeneralSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") GeneralSettingsCommand command, Model model) throws Exception {
|
||||
protected String doSubmitAction(@ModelAttribute("command") GeneralSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
int themeIndex = Integer.parseInt(command.getThemeIndex());
|
||||
Theme theme = settingsService.getAvailableThemes()[themeIndex];
|
||||
@@ -99,12 +100,14 @@ public class GeneralSettingsController {
|
||||
int localeIndex = Integer.parseInt(command.getLocaleIndex());
|
||||
Locale locale = settingsService.getAvailableLocales()[localeIndex];
|
||||
|
||||
command.setToast(true);
|
||||
command.setReloadNeeded(!settingsService.getIndexString().equals(command.getIndex()) ||
|
||||
!settingsService.getIgnoredArticles().equals(command.getIgnoredArticles()) ||
|
||||
!settingsService.getShortcuts().equals(command.getShortcuts()) ||
|
||||
!settingsService.getThemeId().equals(theme.getId()) ||
|
||||
!settingsService.getLocale().equals(locale));
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
redirectAttributes.addFlashAttribute(
|
||||
"settings_reload",
|
||||
!settingsService.getIndexString().equals(command.getIndex())
|
||||
|| !settingsService.getIgnoredArticles().equals(command.getIgnoredArticles())
|
||||
|| !settingsService.getShortcuts().equals(command.getShortcuts())
|
||||
|| !settingsService.getThemeId().equals(theme.getId())
|
||||
|| !settingsService.getLocale().equals(locale));
|
||||
|
||||
settingsService.setIndexString(command.getIndex());
|
||||
settingsService.setIgnoredArticles(command.getIgnoredArticles());
|
||||
|
||||
+27
-27
@@ -22,11 +22,18 @@ package org.libresonic.player.controller;
|
||||
import org.libresonic.player.domain.InternetRadio;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
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 org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -37,38 +44,35 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class InternetRadioSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/internetRadioSettings")
|
||||
public class InternetRadioSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String doGet(Model model) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
if (isFormSubmission(request)) {
|
||||
String error = handleParameters(request);
|
||||
map.put("error", error);
|
||||
if (error == null) {
|
||||
map.put("reload", true);
|
||||
}
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("internetRadios", settingsService.getAllInternetRadios(true));
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
model.addAttribute("model", map);
|
||||
return "internetRadioSettings";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given request represents a form submission.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @return if the request represents a form submission
|
||||
*/
|
||||
private boolean isFormSubmission(HttpServletRequest request) {
|
||||
return "POST".equals(request.getMethod());
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
String error = handleParameters(request);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if(error == null) {
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
redirectAttributes.addFlashAttribute("settings_reload", true);
|
||||
}
|
||||
redirectAttributes.addFlashAttribute("error", error);
|
||||
return "redirect:internetRadioSettings.view";
|
||||
}
|
||||
|
||||
private String handleParameters(HttpServletRequest request) {
|
||||
@@ -116,8 +120,4 @@ public class InternetRadioSettingsController extends ParameterizableViewControll
|
||||
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-3
@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -65,7 +66,6 @@ public class MusicFolderSettingsController {
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow,
|
||||
@RequestParam(value = "expunge",required = false) String expunge,
|
||||
@RequestParam(value = "reload",required = false) String reload,
|
||||
Model model) throws Exception {
|
||||
MusicFolderSettingsCommand command = new MusicFolderSettingsCommand();
|
||||
|
||||
@@ -84,7 +84,6 @@ public class MusicFolderSettingsController {
|
||||
command.setScanning(mediaScannerService.isScanning());
|
||||
command.setMusicFolders(wrap(settingsService.getAllMusicFolders(true, true)));
|
||||
command.setNewMusicFolder(new MusicFolderSettingsCommand.MusicFolderInfo());
|
||||
command.setReload(reload != null || scanNow != null);
|
||||
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public class MusicFolderSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, Model model) throws Exception {
|
||||
protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
|
||||
if (musicFolderInfo.isDelete()) {
|
||||
@@ -129,6 +128,10 @@ public class MusicFolderSettingsController {
|
||||
settingsService.setOrganizeByFolderStructure(command.isOrganizeByFolderStructure());
|
||||
settingsService.save();
|
||||
|
||||
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
redirectAttributes.addFlashAttribute("settings_reload", true);
|
||||
|
||||
mediaScannerService.schedule();
|
||||
return "redirect:musicFolderSettings.view";
|
||||
}
|
||||
|
||||
+6
-3
@@ -30,6 +30,7 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -65,8 +66,7 @@ public class NetworkSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") NetworkSettingsCommand command, Model model) throws Exception {
|
||||
command.setToast(true);
|
||||
protected String doSubmitAction(@ModelAttribute("command") NetworkSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled());
|
||||
settingsService.setUrlRedirectionEnabled(command.isUrlRedirectionEnabled());
|
||||
@@ -82,7 +82,10 @@ public class NetworkSettingsController {
|
||||
settingsService.save();
|
||||
networkService.initPortForwarding(0);
|
||||
networkService.initUrlRedirection(true);
|
||||
return "networkSettings";
|
||||
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
|
||||
return "redirect:networkSettings.view";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-4
@@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -112,7 +114,7 @@ public class PersonalSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") PersonalSettingsCommand command,Model model) throws Exception {
|
||||
protected String doSubmitAction(@ModelAttribute("command") PersonalSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
int localeIndex = Integer.parseInt(command.getLocaleIndex());
|
||||
Locale locale = null;
|
||||
@@ -158,10 +160,10 @@ public class PersonalSettingsController {
|
||||
settings.setChanged(new Date());
|
||||
settingsService.updateUserSettings(settings);
|
||||
|
||||
command.setReloadNeeded(true);
|
||||
redirectAttributes.addFlashAttribute("settings_reload", true);
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
|
||||
model.addAttribute("command",command);
|
||||
return "personalSettings";
|
||||
return "redirect:personalSettings.view";
|
||||
}
|
||||
|
||||
private int getAvatarId(UserSettings userSettings) {
|
||||
|
||||
+5
-2
@@ -33,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -104,7 +106,7 @@ public class PlayerSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, Model model) throws Exception {
|
||||
protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
Player player = playerService.getPlayerById(command.getPlayerId());
|
||||
|
||||
player.setAutoControlEnabled(command.isAutoControlEnabled());
|
||||
@@ -117,7 +119,8 @@ public class PlayerSettingsController {
|
||||
playerService.updatePlayer(player);
|
||||
transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds());
|
||||
|
||||
command.setReloadNeeded(true);
|
||||
redirectAttributes.addFlashAttribute("settings_reload", true);
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
return "redirect:playerSettings.view";
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -28,6 +28,7 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate the Podcast receiver.
|
||||
@@ -57,9 +58,7 @@ public class PodcastSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute PodcastSettingsCommand command, Model model) throws Exception {
|
||||
command.setToast(true);
|
||||
|
||||
protected String doSubmitAction(@ModelAttribute PodcastSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
settingsService.setPodcastUpdateInterval(Integer.parseInt(command.getInterval()));
|
||||
settingsService.setPodcastEpisodeRetentionCount(Integer.parseInt(command.getEpisodeRetentionCount()));
|
||||
settingsService.setPodcastEpisodeDownloadCount(Integer.parseInt(command.getEpisodeDownloadCount()));
|
||||
@@ -67,8 +66,8 @@ public class PodcastSettingsController {
|
||||
settingsService.save();
|
||||
|
||||
podcastService.schedule();
|
||||
model.addAttribute("command",command);
|
||||
return "podcastSettings";
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
return "redirect:podcastSettings.view";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+33
-49
@@ -19,21 +19,8 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
import org.libresonic.player.domain.MediaFile;
|
||||
import org.libresonic.player.domain.MusicFolder;
|
||||
import org.libresonic.player.domain.Share;
|
||||
@@ -42,46 +29,59 @@ import org.libresonic.player.service.MediaFileService;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.libresonic.player.service.ShareService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
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.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate the set of shared media.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class ShareSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/shareSettings")
|
||||
public class ShareSettingsController {
|
||||
|
||||
@Autowired
|
||||
private ShareService shareService;
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private MediaFileService mediaFileService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String doGet(HttpServletRequest request, Model model) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
if (isFormSubmission(request)) {
|
||||
handleParameters(request);
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("shareBaseUrl", shareService.getShareBaseUrl());
|
||||
map.put("shareInfos", getShareInfos(request));
|
||||
map.put("user", securityService.getCurrentUser(request));
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
model.addAttribute("model", map);
|
||||
return "shareSettings";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given request represents a form submission.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @return if the request represents a form submission
|
||||
*/
|
||||
private boolean isFormSubmission(HttpServletRequest request) {
|
||||
return "POST".equals(request.getMethod());
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
||||
handleParameters(request);
|
||||
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
|
||||
return "redirect:shareSettings.view";
|
||||
}
|
||||
|
||||
private void handleParameters(HttpServletRequest request) {
|
||||
@@ -147,22 +147,6 @@ public class ShareSettingsController extends ParameterizableViewController {
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
|
||||
public void setShareService(ShareService shareService) {
|
||||
this.shareService = shareService;
|
||||
}
|
||||
|
||||
public void setMediaFileService(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public static class ShareInfo {
|
||||
private final Share share;
|
||||
private final MediaFile dir;
|
||||
|
||||
+28
-28
@@ -18,56 +18,54 @@
|
||||
*/
|
||||
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.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.libresonic.player.service.SonosService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
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.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate the Sonos music service settings.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class SonosSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/sonosSettings")
|
||||
public class SonosSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private SonosService sonosService;
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String doGet(Model model) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
if (isFormSubmission(request)) {
|
||||
handleParameters(request);
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("sonosEnabled", settingsService.isSonosEnabled());
|
||||
map.put("sonosServiceName", settingsService.getSonosServiceName());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
model.addAttribute("model", map);
|
||||
return "sonosSettings";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given request represents a form submission.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @return if the request represents a form submission
|
||||
*/
|
||||
private boolean isFormSubmission(HttpServletRequest request) {
|
||||
return "POST".equals(request.getMethod());
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
||||
handleParameters(request);
|
||||
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
|
||||
return "redirect:sonosSettings.view";
|
||||
}
|
||||
|
||||
private void handleParameters(HttpServletRequest request) {
|
||||
@@ -84,6 +82,7 @@ public class SonosSettingsController extends ParameterizableViewController {
|
||||
sonosService.setMusicServiceEnabled(false);
|
||||
sonosService.setMusicServiceEnabled(sonosEnabled);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
@@ -93,3 +92,4 @@ public class SonosSettingsController extends ParameterizableViewController {
|
||||
this.sonosService = sonosService;
|
||||
}
|
||||
}
|
||||
=======
|
||||
|
||||
+38
-39
@@ -23,11 +23,17 @@ import org.libresonic.player.domain.Transcoding;
|
||||
import org.libresonic.player.service.TranscodingService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
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 org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -36,43 +42,41 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class TranscodingSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/transcodingSettings")
|
||||
public class TranscodingSettingsController {
|
||||
|
||||
@Autowired
|
||||
private TranscodingService transcodingService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String doGet(Model model) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
if (isFormSubmission(request)) {
|
||||
handleParameters(request, map);
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("transcodings", transcodingService.getAllTranscodings());
|
||||
map.put("transcodeDirectory", transcodingService.getTranscodeDirectory());
|
||||
map.put("downsampleCommand", settingsService.getDownsamplingCommand());
|
||||
map.put("hlsCommand", settingsService.getHlsCommand());
|
||||
map.put("brand", settingsService.getBrand());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
model.addAttribute("model", map);
|
||||
return "transcodingSettings";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given request represents a form submission.
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @return if the request represents a form submission
|
||||
*/
|
||||
private boolean isFormSubmission(HttpServletRequest request) {
|
||||
return "POST".equals(request.getMethod());
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
|
||||
String error = handleParameters(request, redirectAttributes);
|
||||
if(error != null) {
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
}
|
||||
redirectAttributes.addFlashAttribute("error", error);
|
||||
return "redirect:transcodingSettings.view";
|
||||
}
|
||||
|
||||
private void handleParameters(HttpServletRequest request, Map<String, Object> map) {
|
||||
private String handleParameters(HttpServletRequest request, RedirectAttributes redirectAttributes) {
|
||||
|
||||
for (Transcoding transcoding : transcodingService.getAllTranscodings()) {
|
||||
Integer id = transcoding.getId();
|
||||
@@ -86,13 +90,13 @@ public class TranscodingSettingsController extends ParameterizableViewController
|
||||
if (delete) {
|
||||
transcodingService.deleteTranscoding(id);
|
||||
} else if (name == null) {
|
||||
map.put("error", "transcodingsettings.noname");
|
||||
return "transcodingsettings.noname";
|
||||
} else if (sourceFormats == null) {
|
||||
map.put("error", "transcodingsettings.nosourceformat");
|
||||
return "transcodingsettings.nosourceformat";
|
||||
} else if (targetFormat == null) {
|
||||
map.put("error", "transcodingsettings.notargetformat");
|
||||
return "transcodingsettings.notargetformat";
|
||||
} else if (step1 == null) {
|
||||
map.put("error", "transcodingsettings.nostep1");
|
||||
return "transcodingsettings.nostep1";
|
||||
} else {
|
||||
transcoding.setName(name);
|
||||
transcoding.setSourceFormats(sourceFormats);
|
||||
@@ -112,35 +116,30 @@ public class TranscodingSettingsController extends ParameterizableViewController
|
||||
|
||||
if (name != null || sourceFormats != null || targetFormat != null || step1 != null || step2 != null) {
|
||||
Transcoding transcoding = new Transcoding(null, name, sourceFormats, targetFormat, step1, step2, null, defaultActive);
|
||||
String error = null;
|
||||
if (name == null) {
|
||||
map.put("error", "transcodingsettings.noname");
|
||||
error = "transcodingsettings.noname";
|
||||
} else if (sourceFormats == null) {
|
||||
map.put("error", "transcodingsettings.nosourceformat");
|
||||
error = "transcodingsettings.nosourceformat";
|
||||
} else if (targetFormat == null) {
|
||||
map.put("error", "transcodingsettings.notargetformat");
|
||||
error = "transcodingsettings.notargetformat";
|
||||
} else if (step1 == null) {
|
||||
map.put("error", "transcodingsettings.nostep1");
|
||||
error = "transcodingsettings.nostep1";
|
||||
} else {
|
||||
transcodingService.createTranscoding(transcoding);
|
||||
}
|
||||
if (map.containsKey("error")) {
|
||||
map.put("newTranscoding", transcoding);
|
||||
if(error != null) {
|
||||
redirectAttributes.addAttribute("newTranscoding", transcoding);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
settingsService.setDownsamplingCommand(StringUtils.trim(request.getParameter("downsampleCommand")));
|
||||
settingsService.setHlsCommand(StringUtils.trim(request.getParameter("hlsCommand")));
|
||||
settingsService.save();
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getParameter(HttpServletRequest request, String name, Integer id) {
|
||||
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
|
||||
}
|
||||
|
||||
public void setTranscodingService(TranscodingService transcodingService) {
|
||||
this.transcodingService = transcodingService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-43
@@ -40,6 +40,8 @@ import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -51,7 +53,6 @@ import java.util.List;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/userSettings")
|
||||
@SessionAttributes(value = "command")
|
||||
public class UserSettingsController {
|
||||
|
||||
@Autowired
|
||||
@@ -69,37 +70,31 @@ public class UserSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "userSettings";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(HttpServletRequest request,Model model) throws Exception {
|
||||
protected String displayForm(HttpServletRequest request, Model model) throws Exception {
|
||||
UserSettingsCommand command = new UserSettingsCommand();
|
||||
|
||||
User user = getUser(request);
|
||||
if (user != null) {
|
||||
command.setUser(user);
|
||||
command.setEmail(user.getEmail());
|
||||
command.setAdmin(User.USERNAME_ADMIN.equals(user.getUsername()));
|
||||
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
|
||||
command.setTranscodeSchemeName(userSettings.getTranscodeScheme().name());
|
||||
|
||||
} else {
|
||||
command.setNewUser(true);
|
||||
command.setStreamRole(true);
|
||||
command.setSettingsRole(true);
|
||||
}
|
||||
|
||||
command.setUsers(securityService.getAllUsers());
|
||||
command.setTranscodingSupported(transcodingService.isDownsamplingSupported(null));
|
||||
command.setTranscodeDirectory(transcodingService.getTranscodeDirectory().getPath());
|
||||
command.setTranscodeSchemes(TranscodeScheme.values());
|
||||
command.setLdapEnabled(settingsService.isLdapEnabled());
|
||||
command.setAllMusicFolders(settingsService.getAllMusicFolders());
|
||||
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
|
||||
User user = getUser(request);
|
||||
if (user != null) {
|
||||
command.setUser(user);
|
||||
command.setEmail(user.getEmail());
|
||||
command.setAdmin(User.USERNAME_ADMIN.equals(user.getUsername()));
|
||||
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
|
||||
command.setTranscodeSchemeName(userSettings.getTranscodeScheme().name());
|
||||
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
|
||||
} else {
|
||||
command.setNewUser(true);
|
||||
command.setStreamRole(true);
|
||||
command.setSettingsRole(true);
|
||||
}
|
||||
|
||||
model.addAttribute("command",command);
|
||||
return "userSettings";
|
||||
}
|
||||
|
||||
private User getUser(HttpServletRequest request) throws ServletRequestBindingException {
|
||||
@@ -126,7 +121,7 @@ public class UserSettingsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command) throws Exception {
|
||||
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
|
||||
|
||||
if (command.isDeleteUser()) {
|
||||
deleteUser(command);
|
||||
@@ -135,9 +130,10 @@ public class UserSettingsController {
|
||||
} else {
|
||||
updateUser(command);
|
||||
}
|
||||
resetCommand(command);
|
||||
redirectAttributes.addFlashAttribute("settings_reload", true);
|
||||
redirectAttributes.addFlashAttribute("settings_toast", true);
|
||||
|
||||
return "userSettings";
|
||||
return "redirect:userSettings.view";
|
||||
}
|
||||
|
||||
private void deleteUser(UserSettingsCommand command) {
|
||||
@@ -181,22 +177,4 @@ public class UserSettingsController {
|
||||
settingsService.setMusicFoldersForUser(command.getUsername(), allowedMusicFolderIds);
|
||||
}
|
||||
|
||||
private void resetCommand(UserSettingsCommand command) {
|
||||
command.setUser(null);
|
||||
command.setUsers(securityService.getAllUsers());
|
||||
command.setDeleteUser(false);
|
||||
command.setPasswordChange(false);
|
||||
command.setNewUser(true);
|
||||
command.setStreamRole(true);
|
||||
command.setSettingsRole(true);
|
||||
command.setPassword(null);
|
||||
command.setConfirmPassword(null);
|
||||
command.setEmail(null);
|
||||
command.setTranscodeSchemeName(null);
|
||||
command.setAllMusicFolders(settingsService.getAllMusicFolders());
|
||||
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(null)));
|
||||
command.setToast(true);
|
||||
command.setReload(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package org.libresonic.player.spring;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.libresonic.player.Logger;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
public class LoggingExceptionResolver implements HandlerExceptionResolver, Ordered {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(LoggingExceptionResolver.class);
|
||||
|
||||
@Override
|
||||
public ModelAndView resolveException(
|
||||
HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e
|
||||
) {
|
||||
logger.error("Exception occurred", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="advanced"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form:form method="post" action="advancedSettings.view" commandName="command">
|
||||
@@ -143,7 +143,7 @@
|
||||
|
||||
</form:form>
|
||||
|
||||
<c:if test="${command.reloadNeeded}">
|
||||
<c:if test="${settings_reload}">
|
||||
<script language="javascript" type="text/javascript">
|
||||
parent.frames.left.location.href="left.view?";
|
||||
parent.frames.playQueue.location.href="playQueue.view?";
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="dlna"/>
|
||||
<c:param name="toast" value="${model.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form method="post" action="dlnaSettings.view">
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="general"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form:form method="post" action="generalSettings.view" commandName="command">
|
||||
@@ -165,7 +165,7 @@
|
||||
</table>
|
||||
</form:form>
|
||||
|
||||
<c:if test="${command.reloadNeeded}">
|
||||
<c:if test="${settings_reload}">
|
||||
<script language="javascript" type="text/javascript">
|
||||
parent.frames.left.location.href="left.view?";
|
||||
parent.frames.playQueue.location.href="playQueue.view?";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="internetRadio"/>
|
||||
<c:param name="toast" value="${model.reload}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form method="post" action="internetRadioSettings.view">
|
||||
@@ -55,11 +55,11 @@
|
||||
</form>
|
||||
|
||||
|
||||
<c:if test="${not empty model.error}">
|
||||
<p class="warning"><fmt:message key="${model.error}"/></p>
|
||||
<c:if test="${not empty error}">
|
||||
<p class="warning"><fmt:message key="${error}"/></p>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${model.reload}">
|
||||
<c:if test="${settings_reload}">
|
||||
<script language="javascript" type="text/javascript">parent.frames.left.location.href="left.view?"</script>
|
||||
</c:if>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
$("#newMusicFolderName").attr("placeholder", "<fmt:message key="musicfoldersettings.name"/>");
|
||||
$("#newMusicFolderPath").attr("placeholder", "<fmt:message key="musicfoldersettings.path"/>");
|
||||
|
||||
<c:if test="${command.reload}">
|
||||
<c:if test="${settings_reload}">
|
||||
parent.frames.upper.location.href="top.view?";
|
||||
parent.frames.left.location.href="left.view?";
|
||||
parent.frames.right.location.href="right.view?";
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="musicFolder"/>
|
||||
<c:param name="toast" value="${command.reload}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form:form commandName="command" action="musicFolderSettings.view" method="post">
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="network"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<p style="padding-top:1em"><fmt:message key="networksettings.text"/></p>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="password"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
<c:param name="restricted" value="true"/>
|
||||
</c:import>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="personal"/>
|
||||
<c:param name="restricted" value="${not command.user.adminRole}"/>
|
||||
<c:param name="toast" value="${command.reloadNeeded}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<fmt:message key="personalsettings.title" var="title"><fmt:param>${command.user.username}</fmt:param></fmt:message>
|
||||
@@ -254,7 +254,7 @@
|
||||
<fmt:message key="personalsettings.avatar.courtesy"/>
|
||||
</p>
|
||||
|
||||
<c:if test="${command.reloadNeeded}">
|
||||
<c:if test="${settings_reload}">
|
||||
<script language="javascript" type="text/javascript">
|
||||
parent.location.href="index.view?";
|
||||
</script>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="player"/>
|
||||
<c:param name="toast" value="${command.reloadNeeded}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
<c:param name="restricted" value="${not command.admin}"/>
|
||||
</c:import>
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<c:if test="${command.reloadNeeded}">
|
||||
<c:if test="${settings_reload}">
|
||||
<script language="javascript" type="text/javascript">parent.frames.playQueue.location.href="playQueue.view?"</script>
|
||||
</c:if>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="podcast"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form:form commandName="command" action="podcastSettings.view" method="post">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="premium"/>
|
||||
<c:param name="restricted" value="${not command.user.adminRole}"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<c:if test="${not empty command.path}">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="share"/>
|
||||
<c:param name="toast" value="${model.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
<c:param name="restricted" value="${not model.user.adminRole}"/>
|
||||
</c:import>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="sonos"/>
|
||||
<c:param name="toast" value="${model.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form method="post" action="sonosSettings.view">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="transcoding"/>
|
||||
<c:param name="toast" value="${model.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<form method="post" action="transcodingSettings.view">
|
||||
@@ -40,11 +40,11 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input style="font-family:monospace" type="text" name="name" size="10" placeholder="<fmt:message key="transcodingsettings.name"/>" value="${model.newTranscoding.name}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="sourceFormats" size="36" placeholder="<fmt:message key="transcodingsettings.sourceformat"/>" value="${model.newTranscoding.sourceFormats}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="targetFormat" size="10" placeholder="<fmt:message key="transcodingsettings.targetformat"/>" value="${model.newTranscoding.targetFormat}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="step1" size="60" placeholder="<fmt:message key="transcodingsettings.step1"/>" value="${model.newTranscoding.step1}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="step2" size="22" placeholder="<fmt:message key="transcodingsettings.step2"/>" value="${model.newTranscoding.step2}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="name" size="10" placeholder="<fmt:message key="transcodingsettings.name"/>" value="${newTranscoding.name}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="sourceFormats" size="36" placeholder="<fmt:message key="transcodingsettings.sourceformat"/>" value="${newTranscoding.sourceFormats}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="targetFormat" size="10" placeholder="<fmt:message key="transcodingsettings.targetformat"/>" value="${newTranscoding.targetFormat}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="step1" size="60" placeholder="<fmt:message key="transcodingsettings.step1"/>" value="${newTranscoding.step1}"/></td>
|
||||
<td><input style="font-family:monospace" type="text" name="step2" size="22" placeholder="<fmt:message key="transcodingsettings.step2"/>" value="${newTranscoding.step2}"/></td>
|
||||
<td/>
|
||||
</tr>
|
||||
|
||||
@@ -87,8 +87,8 @@
|
||||
|
||||
</form>
|
||||
|
||||
<c:if test="${not empty model.error}">
|
||||
<p class="warning"><fmt:message key="${model.error}"/></p>
|
||||
<c:if test="${not empty error}">
|
||||
<p class="warning"><fmt:message key="${error}"/></p>
|
||||
</c:if>
|
||||
|
||||
<div style="width:60%">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<script type="text/javascript">
|
||||
function init() {
|
||||
enablePasswordChangeFields();
|
||||
<c:if test="${command.reload}">
|
||||
<c:if test="${settings_reload}">
|
||||
parent.frames.left.location.href="left.view?";
|
||||
</c:if>
|
||||
}
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<c:import url="settingsHeader.jsp">
|
||||
<c:param name="cat" value="user"/>
|
||||
<c:param name="toast" value="${command.toast}"/>
|
||||
<c:param name="toast" value="${settings_toast}"/>
|
||||
</c:import>
|
||||
|
||||
<table class="indent">
|
||||
@@ -61,9 +61,8 @@
|
||||
|
||||
<p/>
|
||||
|
||||
<form:form method="post" action="userSettings.view" commandName="command">
|
||||
<c:if test="${not command.admin}">
|
||||
<table>
|
||||
<form:form method="post" action="userSettings.view" modelAttribute="command">
|
||||
<table style="${command.admin ? 'display:none' : ''}">
|
||||
<tr>
|
||||
<td><form:checkbox path="adminRole" id="admin" cssClass="checkbox"/></td>
|
||||
<td><label for="admin"><fmt:message key="usersettings.admin"/></label></td>
|
||||
@@ -105,7 +104,6 @@
|
||||
<td><label for="podcast"><fmt:message key="usersettings.podcast"/></label></td>
|
||||
</tr>
|
||||
</table>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${not empty command.allMusicFolders}">
|
||||
<h2><fmt:message key="usersettings.folderaccess"/></h2>
|
||||
@@ -158,7 +156,7 @@
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${command.newUser}">
|
||||
|
||||
<div style="display:none"><form:input path="newUser" /></div>
|
||||
<table class="indent">
|
||||
<tr>
|
||||
<td><fmt:message key="usersettings.username"/></td>
|
||||
@@ -184,6 +182,7 @@
|
||||
</c:when>
|
||||
|
||||
<c:otherwise>
|
||||
<div style="display:none"><form:input path="username"/></div>
|
||||
<table id="passwordChangeCheckboxTable">
|
||||
<tr>
|
||||
<td><form:checkbox path="passwordChange" id="passwordChange" onclick="enablePasswordChangeFields();" cssClass="checkbox"/></td>
|
||||
|
||||
@@ -145,33 +145,6 @@
|
||||
<bean id="settingsController" class="org.libresonic.player.controller.SettingsController">
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="dlnaSettingsController" class="org.libresonic.player.controller.DLNASettingsController">
|
||||
<property name="viewName" value="dlnaSettings"/>
|
||||
<property name="upnpService" ref="upnpService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="sonosSettingsController" class="org.libresonic.player.controller.SonosSettingsController">
|
||||
<property name="viewName" value="sonosSettings"/>
|
||||
<property name="sonosService" ref="sonosService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="shareSettingsController" class="org.libresonic.player.controller.ShareSettingsController">
|
||||
<property name="viewName" value="shareSettings"/>
|
||||
<property name="shareService" ref="shareService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="mediaFileService" ref="mediaFileService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="transcodingSettingsController" class="org.libresonic.player.controller.TranscodingSettingsController">
|
||||
<property name="viewName" value="transcodingSettings"/>
|
||||
<property name="transcodingService" ref="transcodingService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="internetRadioSettingsController"
|
||||
class="org.libresonic.player.controller.InternetRadioSettingsController">
|
||||
<property name="viewName" value="internetRadioSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="avatarUploadController" class="org.libresonic.player.controller.AvatarUploadController">
|
||||
<property name="viewName" value="avatarUploadResult"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
@@ -344,11 +317,6 @@
|
||||
<prop key="/nowPlaying.view">nowPlayingController</prop>
|
||||
<prop key="/starred.view">starredController</prop>
|
||||
<prop key="/settings.view">settingsController</prop>
|
||||
<prop key="/dlnaSettings.view">dlnaSettingsController</prop>
|
||||
<prop key="/sonosSettings.view">sonosSettingsController</prop>
|
||||
<prop key="/shareSettings.view">shareSettingsController</prop>
|
||||
<prop key="/transcodingSettings.view">transcodingSettingsController</prop>
|
||||
<prop key="/internetRadioSettings.view">internetRadioSettingsController</prop>
|
||||
<prop key="/avatarUpload.view">avatarUploadController</prop>
|
||||
<prop key="/allmusic.view">allmusicController</prop>
|
||||
<prop key="/home.view">homeController</prop>
|
||||
@@ -398,4 +366,5 @@
|
||||
<property name="suffix" value=".jsp"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.libresonic.player.spring.LoggingExceptionResolver" />
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user