From 95159ed298362b56aa499171636e358fb422d81b Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Sat, 17 Dec 2016 10:41:37 -0700 Subject: [PATCH 1/3] Added logging exception resolver Signed-off-by: Andrew DeMaria --- .../spring/LoggingExceptionResolver.java | 26 +++++++++++++++++++ .../webapp/WEB-INF/libresonic-servlet.xml | 1 + 2 files changed, 27 insertions(+) create mode 100644 libresonic-main/src/main/java/org/libresonic/player/spring/LoggingExceptionResolver.java diff --git a/libresonic-main/src/main/java/org/libresonic/player/spring/LoggingExceptionResolver.java b/libresonic-main/src/main/java/org/libresonic/player/spring/LoggingExceptionResolver.java new file mode 100644 index 00000000..14c753a4 --- /dev/null +++ b/libresonic-main/src/main/java/org/libresonic/player/spring/LoggingExceptionResolver.java @@ -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; + } +} diff --git a/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml b/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml index 3c44ef8b..d4295b1d 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml +++ b/libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml @@ -398,4 +398,5 @@ + From 699ea643e2652c02519895cd51afe465851fffbd Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Sun, 18 Dec 2016 19:47:41 -0700 Subject: [PATCH 2/3] Fixes #179 and Fixes #181 Signed-off-by: Andrew DeMaria --- .../command/AdvancedSettingsCommand.java | 15 ---- .../command/GeneralSettingsCommand.java | 14 ---- .../command/MusicFolderSettingsCommand.java | 9 -- .../command/NetworkSettingsCommand.java | 9 -- .../command/PersonalSettingsCommand.java | 9 -- .../player/command/PlayerSettingsCommand.java | 5 -- .../command/PodcastSettingsCommand.java | 8 -- .../player/command/UserSettingsCommand.java | 18 +--- .../AdvancedSettingsController.java | 10 +-- .../controller/DLNASettingsController.java | 51 +++++------- .../controller/GeneralSettingsController.java | 17 ++-- .../InternetRadioSettingsController.java | 54 ++++++------ .../MusicFolderSettingsController.java | 9 +- .../controller/NetworkSettingsController.java | 9 +- .../PersonalSettingsController.java | 10 ++- .../controller/PlayerSettingsController.java | 7 +- .../controller/PodcastSettingsController.java | 9 +- .../controller/ShareSettingsController.java | 82 ++++++++----------- .../controller/SonosSettingsController.java | 62 ++++++-------- .../TranscodingSettingsController.java | 77 +++++++++-------- .../controller/UserSettingsController.java | 52 ++++-------- .../webapp/WEB-INF/jsp/advancedSettings.jsp | 4 +- .../main/webapp/WEB-INF/jsp/dlnaSettings.jsp | 2 +- .../webapp/WEB-INF/jsp/generalSettings.jsp | 4 +- .../WEB-INF/jsp/internetRadioSettings.jsp | 8 +- .../WEB-INF/jsp/musicFolderSettings.jsp | 4 +- .../webapp/WEB-INF/jsp/networkSettings.jsp | 2 +- .../webapp/WEB-INF/jsp/passwordSettings.jsp | 2 +- .../webapp/WEB-INF/jsp/personalSettings.jsp | 4 +- .../webapp/WEB-INF/jsp/playerSettings.jsp | 4 +- .../webapp/WEB-INF/jsp/podcastSettings.jsp | 2 +- .../webapp/WEB-INF/jsp/premiumSettings.jsp | 2 +- .../main/webapp/WEB-INF/jsp/shareSettings.jsp | 2 +- .../main/webapp/WEB-INF/jsp/sonosSettings.jsp | 2 +- .../WEB-INF/jsp/transcodingSettings.jsp | 16 ++-- .../main/webapp/WEB-INF/jsp/userSettings.jsp | 13 ++- .../webapp/WEB-INF/libresonic-servlet.xml | 32 -------- 37 files changed, 238 insertions(+), 401 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java index eaad28af..2f8168e6 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java @@ -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() { diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/GeneralSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/GeneralSettingsCommand.java index 52ffbd47..c8fad18a 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/GeneralSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/GeneralSettingsCommand.java @@ -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; - } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/MusicFolderSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/MusicFolderSettingsCommand.java index 1c45816e..1bb0b546 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/MusicFolderSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/MusicFolderSettingsCommand.java @@ -41,7 +41,6 @@ public class MusicFolderSettingsCommand { private boolean organizeByFolderStructure; private List 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; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/NetworkSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/NetworkSettingsCommand.java index 67fe762b..139ce846 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/NetworkSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/NetworkSettingsCommand.java @@ -33,7 +33,6 @@ public class NetworkSettingsCommand { private String urlRedirectCustomUrl; private String urlRedirectType; private int port; - private boolean toast; private LicenseInfo licenseInfo; public void setPortForwardingEnabled(boolean portForwardingEnabled) { @@ -75,14 +74,6 @@ public class NetworkSettingsCommand { this.port = port; } - public boolean isToast() { - return toast; - } - - public void setToast(boolean toast) { - this.toast = toast; - } - public void setLicenseInfo(LicenseInfo licenseInfo) { this.licenseInfo = licenseInfo; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java index 1f182583..57e3c4ff 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java @@ -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; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/PlayerSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/PlayerSettingsCommand.java index 89260232..3377e44a 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/PlayerSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/PlayerSettingsCommand.java @@ -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; } /** diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/PodcastSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/PodcastSettingsCommand.java index bfe5a136..84ec7dfb 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/PodcastSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/PodcastSettingsCommand.java @@ -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; - } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/UserSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/UserSettingsCommand.java index e10bbc7c..a6d12a59 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/UserSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/UserSettingsCommand.java @@ -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; - } } \ No newline at end of file diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java index 6cbc2392..b86667e9 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java @@ -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"; } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java index 8995c462..7ef6c344 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java @@ -22,53 +22,52 @@ 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 map = new HashMap(); - 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()); map.put("licenseInfo", settingsService.getLicenseInfo()); - 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) { @@ -84,12 +83,4 @@ public class DLNASettingsController extends ParameterizableViewController { settingsService.save(); upnpService.setMediaServerEnabled(dlnaEnabled); } - - public void setSettingsService(SettingsService settingsService) { - this.settingsService = settingsService; - } - - public void setUpnpService(UPnPService upnpService) { - this.upnpService = upnpService; - } } \ No newline at end of file diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/GeneralSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/GeneralSettingsController.java index b549ee56..3355a452 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/GeneralSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/GeneralSettingsController.java @@ -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()); diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/InternetRadioSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/InternetRadioSettingsController.java index 649605b9..c57ac9f5 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/InternetRadioSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/InternetRadioSettingsController.java @@ -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 { - - Map map = new HashMap(); + @RequestMapping(method = RequestMethod.GET) + public String doGet(Model model) throws Exception { - if (isFormSubmission(request)) { - String error = handleParameters(request); - map.put("error", error); - if (error == null) { - map.put("reload", true); - } - } + Map map = new HashMap<>(); - 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 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; - } - } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java index 47a66562..65108f2a 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java @@ -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"; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/NetworkSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/NetworkSettingsController.java index ed341e94..e22be4ae 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/NetworkSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/NetworkSettingsController.java @@ -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; @@ -66,8 +67,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()); @@ -83,7 +83,10 @@ public class NetworkSettingsController { settingsService.save(); networkService.initPortForwarding(0); networkService.initUrlRedirection(true); - return "networkSettings"; + + redirectAttributes.addFlashAttribute("settings_toast", true); + + return "redirect:networkSettings.view"; } } \ No newline at end of file diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java index f09afc82..0a1bd2a9 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java @@ -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) { diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java index 433467bb..0d88f127 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java @@ -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"; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PodcastSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PodcastSettingsController.java index bec26a95..d8dbb347 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PodcastSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PodcastSettingsController.java @@ -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"; } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/ShareSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/ShareSettingsController.java index 19113a73..4d62f1c3 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/ShareSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/ShareSettingsController.java @@ -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,47 +29,60 @@ 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 { - - Map map = new HashMap(); - if (isFormSubmission(request)) { - handleParameters(request); - map.put("toast", true); - } + @RequestMapping(method = RequestMethod.GET) + public String doGet(HttpServletRequest request, Model model) throws Exception { - ModelAndView result = super.handleRequestInternal(request, response); + Map map = new HashMap(); map.put("shareBaseUrl", shareService.getShareBaseUrl()); map.put("shareInfos", getShareInfos(request)); map.put("user", securityService.getCurrentUser(request)); map.put("licenseInfo", settingsService.getLicenseInfo()); - 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) { @@ -148,22 +148,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; diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java index eb8226b6..2ae611d5 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java @@ -18,57 +18,55 @@ */ 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 map = new HashMap(); - 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()); map.put("licenseInfo", settingsService.getLicenseInfo()); - 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) { @@ -85,12 +83,4 @@ public class SonosSettingsController extends ParameterizableViewController { sonosService.setMusicServiceEnabled(false); sonosService.setMusicServiceEnabled(sonosEnabled); } - - public void setSettingsService(SettingsService settingsService) { - this.settingsService = settingsService; - } - - public void setSonosService(SonosService sonosService) { - this.sonosService = sonosService; - } } \ No newline at end of file diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/TranscodingSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/TranscodingSettingsController.java index bd28e172..b857ffda 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/TranscodingSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/TranscodingSettingsController.java @@ -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 map = new HashMap(); - 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 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; - } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/UserSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/UserSettingsController.java index 02b8c294..40a66132 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/UserSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/UserSettingsController.java @@ -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,14 +70,15 @@ 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(); + 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()); User user = getUser(request); if (user != null) { command.setUser(user); @@ -84,22 +86,15 @@ public class UserSettingsController { 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); } - 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))); - 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); - } - } diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp index 69291892..500124c4 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp @@ -18,7 +18,7 @@ - + @@ -143,7 +143,7 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp index de6af01d..48c77a7f 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp @@ -10,7 +10,7 @@ $("#newMusicFolderName").attr("placeholder", ""); $("#newMusicFolderPath").attr("placeholder", ""); - + 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 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/networkSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/networkSettings.jsp index ba80531a..ce369a99 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/networkSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/networkSettings.jsp @@ -43,7 +43,7 @@ - +

diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp index e05aade5..b7010c03 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp @@ -9,7 +9,7 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp index f57974d3..68814c86 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp @@ -20,7 +20,7 @@ - + ${command.user.username} @@ -254,7 +254,7 @@

- + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/playerSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/playerSettings.jsp index 4d16c5f4..7b596d54 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/playerSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/playerSettings.jsp @@ -12,7 +12,7 @@ - + @@ -163,7 +163,7 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/podcastSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/podcastSettings.jsp index c3a7ce48..610d3a43 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/podcastSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/podcastSettings.jsp @@ -9,7 +9,7 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/premiumSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/premiumSettings.jsp index 4d227e1c..0d4f0ab8 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/premiumSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/premiumSettings.jsp @@ -10,7 +10,7 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/shareSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/shareSettings.jsp index c57a4ec0..da505748 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/shareSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/shareSettings.jsp @@ -9,7 +9,7 @@ - + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/sonosSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/sonosSettings.jsp index c0c06c1a..56f183e7 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/sonosSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/sonosSettings.jsp @@ -30,7 +30,7 @@ - +
diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/transcodingSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/transcodingSettings.jsp index 5d1a9c1d..1de70723 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/transcodingSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/transcodingSettings.jsp @@ -10,7 +10,7 @@ - + @@ -40,11 +40,11 @@ - " value="${model.newTranscoding.name}"/> - " value="${model.newTranscoding.sourceFormats}"/> - " value="${model.newTranscoding.targetFormat}"/> - " value="${model.newTranscoding.step1}"/> - " value="${model.newTranscoding.step2}"/> + " value="${newTranscoding.name}"/> + " value="${newTranscoding.sourceFormats}"/> + " value="${newTranscoding.targetFormat}"/> + " value="${newTranscoding.step1}"/> + " value="${newTranscoding.step2}"/> @@ -87,8 +87,8 @@
- -

+ +

diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/userSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/userSettings.jsp index 513c7a7f..8cc25e76 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/userSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/userSettings.jsp @@ -8,7 +8,7 @@