Merge pull request #155 into develop
This commit is contained in:
+7
-12
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.libresonic.player</groupId>
|
||||
<artifactId>libresonic</artifactId>
|
||||
<version>6.1.beta2</version>
|
||||
<version>6.2.beta1.spring4</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -330,6 +330,12 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-core</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
@@ -348,17 +354,6 @@
|
||||
<version>${cxf.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-api</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-common-utilities</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
This file is part of Libresonic.
|
||||
|
||||
Libresonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libresonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors
|
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
|
||||
*/
|
||||
package org.libresonic.player.command;
|
||||
|
||||
import org.libresonic.player.controller.*;
|
||||
|
||||
/**
|
||||
* Command used in {@link PasswordSettingsController}.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PasswordSettingsCommand {
|
||||
private String username;
|
||||
private String password;
|
||||
private String confirmPassword;
|
||||
private boolean ldapAuthenticated;
|
||||
private boolean toast;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getConfirmPassword() {
|
||||
return confirmPassword;
|
||||
}
|
||||
|
||||
public void setConfirmPassword(String confirmPassword) {
|
||||
this.confirmPassword = confirmPassword;
|
||||
}
|
||||
|
||||
public boolean isLdapAuthenticated() {
|
||||
return ldapAuthenticated;
|
||||
}
|
||||
|
||||
public void setLdapAuthenticated(boolean ldapAuthenticated) {
|
||||
this.ldapAuthenticated = ldapAuthenticated;
|
||||
}
|
||||
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
|
||||
public void setToast(boolean toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
}
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
This file is part of Libresonic.
|
||||
|
||||
Libresonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libresonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors
|
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
|
||||
*/
|
||||
package org.libresonic.player.command;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.libresonic.player.controller.PremiumSettingsController;
|
||||
import org.libresonic.player.domain.LicenseInfo;
|
||||
import org.libresonic.player.domain.User;
|
||||
|
||||
/**
|
||||
* Command used in {@link PremiumSettingsController}.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PremiumSettingsCommand {
|
||||
|
||||
private String path;
|
||||
private String brand;
|
||||
private LicenseInfo licenseInfo;
|
||||
private String licenseCode;
|
||||
private boolean forceChange;
|
||||
private boolean submissionError;
|
||||
private User user;
|
||||
private boolean toast;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getBrand() {
|
||||
return brand;
|
||||
}
|
||||
|
||||
public void setBrand(String brand) {
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
public LicenseInfo getLicenseInfo() {
|
||||
return licenseInfo;
|
||||
}
|
||||
|
||||
public String getLicenseCode() {
|
||||
return licenseCode;
|
||||
}
|
||||
|
||||
public void setLicenseCode(String licenseCode) {
|
||||
this.licenseCode = StringUtils.trimToNull(licenseCode);
|
||||
}
|
||||
|
||||
public void setLicenseInfo(LicenseInfo licenseInfo) {
|
||||
this.licenseInfo = licenseInfo;
|
||||
}
|
||||
|
||||
public boolean isForceChange() {
|
||||
return forceChange;
|
||||
}
|
||||
|
||||
public void setForceChange(boolean forceChange) {
|
||||
this.forceChange = forceChange;
|
||||
}
|
||||
|
||||
public boolean isSubmissionError() {
|
||||
return submissionError;
|
||||
}
|
||||
|
||||
public void setSubmissionError(boolean submissionError) {
|
||||
this.submissionError = submissionError;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setToast(boolean toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
|
||||
public boolean isToast() {
|
||||
return toast;
|
||||
}
|
||||
}
|
||||
+22
-15
@@ -19,24 +19,33 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.libresonic.player.command.AdvancedSettingsCommand;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate advanced settings.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class AdvancedSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/advancedSettings")
|
||||
public class AdvancedSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
// TODO replace with @GetMapping in Spring 4
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String formBackingObject(Model model) throws Exception {
|
||||
AdvancedSettingsCommand command = new AdvancedSettingsCommand();
|
||||
command.setDownloadLimit(String.valueOf(settingsService.getDownloadBitrateLimit()));
|
||||
command.setUploadLimit(String.valueOf(settingsService.getUploadBitrateLimit()));
|
||||
@@ -53,12 +62,12 @@ public class AdvancedSettingsController extends SimpleFormController {
|
||||
command.setSmtpUser(settingsService.getSmtpUser());
|
||||
command.setSmtpFrom(settingsService.getSmtpFrom());
|
||||
|
||||
return command;
|
||||
model.addAttribute("command", command);
|
||||
return "advancedSettings";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
AdvancedSettingsCommand command = (AdvancedSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute AdvancedSettingsCommand command,Model model) throws Exception {
|
||||
|
||||
command.setToast(true);
|
||||
command.setReloadNeeded(false);
|
||||
@@ -90,10 +99,8 @@ public class AdvancedSettingsController extends SimpleFormController {
|
||||
settingsService.setSmtpPassword(command.getSmtpPassword());
|
||||
}
|
||||
|
||||
settingsService.save();
|
||||
model.addAttribute("command", command);
|
||||
return "advancedSettings";
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
}
|
||||
|
||||
+24
-15
@@ -19,26 +19,37 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
import org.libresonic.player.command.GeneralSettingsCommand;
|
||||
import org.libresonic.player.domain.Theme;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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 java.util.Locale;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate general settings.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class GeneralSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/generalSettings")
|
||||
public class GeneralSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "generalSettings";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(Model model) throws Exception {
|
||||
GeneralSettingsCommand command = new GeneralSettingsCommand();
|
||||
command.setCoverArtFileTypes(settingsService.getCoverArtFileTypes());
|
||||
command.setIgnoredArticles(settingsService.getIgnoredArticles());
|
||||
@@ -76,12 +87,11 @@ public class GeneralSettingsController extends SimpleFormController {
|
||||
}
|
||||
command.setLocales(localeStrings);
|
||||
|
||||
return command;
|
||||
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
GeneralSettingsCommand command = (GeneralSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") GeneralSettingsCommand command, Model model) throws Exception {
|
||||
|
||||
int themeIndex = Integer.parseInt(command.getThemeIndex());
|
||||
Theme theme = settingsService.getAvailableThemes()[themeIndex];
|
||||
@@ -112,9 +122,8 @@ public class GeneralSettingsController extends SimpleFormController {
|
||||
settingsService.setThemeId(theme.getId());
|
||||
settingsService.setLocale(locale);
|
||||
settingsService.save();
|
||||
|
||||
return "redirect:generalSettings.view";
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import org.libresonic.player.Logger;
|
||||
import org.libresonic.player.domain.User;
|
||||
import org.libresonic.player.service.PlaylistService;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.libresonic.player.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Spring MVC Controller that serves the login page.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/login")
|
||||
public class LoginController {
|
||||
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(LoginController.class);
|
||||
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
|
||||
public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
// Auto-login if "user" and "password" parameters are given.
|
||||
String username = request.getParameter("user");
|
||||
String password = request.getParameter("password");
|
||||
if (username != null && password != null) {
|
||||
username = StringUtil.urlEncode(username);
|
||||
password = StringUtil.urlEncode(password);
|
||||
return new ModelAndView(new RedirectView("/j_spring_security_check?"+
|
||||
UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY+"=" + username +
|
||||
"&"+UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY+"=" + password
|
||||
));
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("logout", request.getParameter("logout") != null);
|
||||
map.put("error", request.getParameter("error") != null);
|
||||
map.put("brand", settingsService.getBrand());
|
||||
map.put("loginMessage", settingsService.getLoginMessage());
|
||||
|
||||
User admin = securityService.getUserByName(User.USERNAME_ADMIN);
|
||||
if (User.USERNAME_ADMIN.equals(admin.getPassword())) {
|
||||
map.put("insecure", true);
|
||||
}
|
||||
|
||||
return new ModelAndView("login", "model", map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,34 +64,6 @@ public class MultiController extends MultiActionController {
|
||||
private SettingsService settingsService;
|
||||
private PlaylistService playlistService;
|
||||
|
||||
public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
// Auto-login if "user" and "password" parameters are given.
|
||||
String username = request.getParameter("user");
|
||||
String password = request.getParameter("password");
|
||||
if (username != null && password != null) {
|
||||
username = StringUtil.urlEncode(username);
|
||||
password = StringUtil.urlEncode(password);
|
||||
return new ModelAndView(new RedirectView("/j_spring_security_check?"+
|
||||
UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY+"=" + username +
|
||||
"&"+UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY+"=" + password
|
||||
));
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("logout", request.getParameter("logout") != null);
|
||||
map.put("error", request.getParameter("error") != null);
|
||||
map.put("brand", settingsService.getBrand());
|
||||
map.put("loginMessage", settingsService.getLoginMessage());
|
||||
|
||||
User admin = securityService.getUserByName(User.USERNAME_ADMIN);
|
||||
if (User.USERNAME_ADMIN.equals(admin.getPassword())) {
|
||||
map.put("insecure", true);
|
||||
}
|
||||
|
||||
return new ModelAndView("login", "model", map);
|
||||
}
|
||||
|
||||
public ModelAndView recover(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
+34
-34
@@ -26,12 +26,14 @@ import org.libresonic.player.dao.MediaFileDao;
|
||||
import org.libresonic.player.domain.MusicFolder;
|
||||
import org.libresonic.player.service.MediaScannerService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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.bind.annotation.RequestParam;
|
||||
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,22 +42,38 @@ import java.util.List;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class MusicFolderSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/musicFolderSettings")
|
||||
public class MusicFolderSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private MediaScannerService mediaScannerService;
|
||||
@Autowired
|
||||
private ArtistDao artistDao;
|
||||
@Autowired
|
||||
private AlbumDao albumDao;
|
||||
@Autowired
|
||||
private MediaFileDao mediaFileDao;
|
||||
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "musicFolderSettings";
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
if (request.getParameter("scanNow") != null) {
|
||||
if (scanNow != null) {
|
||||
settingsService.clearMusicFolderCache();
|
||||
mediaScannerService.scanLibrary();
|
||||
}
|
||||
if (request.getParameter("expunge") != null) {
|
||||
if (expunge != null) {
|
||||
expunge();
|
||||
}
|
||||
|
||||
@@ -66,10 +84,12 @@ public class MusicFolderSettingsController extends SimpleFormController {
|
||||
command.setScanning(mediaScannerService.isScanning());
|
||||
command.setMusicFolders(wrap(settingsService.getAllMusicFolders(true, true)));
|
||||
command.setNewMusicFolder(new MusicFolderSettingsCommand.MusicFolderInfo());
|
||||
command.setReload(request.getParameter("reload") != null || request.getParameter("scanNow") != null);
|
||||
return command;
|
||||
command.setReload(reload != null || scanNow != null);
|
||||
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
|
||||
|
||||
private void expunge() {
|
||||
artistDao.expunge();
|
||||
albumDao.expunge();
|
||||
@@ -84,9 +104,8 @@ public class MusicFolderSettingsController extends SimpleFormController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelAndView onSubmit(Object comm) throws Exception {
|
||||
MusicFolderSettingsCommand command = (MusicFolderSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, Model model) throws Exception {
|
||||
|
||||
for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
|
||||
if (musicFolderInfo.isDelete()) {
|
||||
@@ -111,26 +130,7 @@ public class MusicFolderSettingsController extends SimpleFormController {
|
||||
settingsService.save();
|
||||
|
||||
mediaScannerService.schedule();
|
||||
return new ModelAndView(new RedirectView(getSuccessView() + ".view?reload"));
|
||||
return "redirect:musicFolderSettings.view";
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setMediaScannerService(MediaScannerService mediaScannerService) {
|
||||
this.mediaScannerService = mediaScannerService;
|
||||
}
|
||||
|
||||
public void setArtistDao(ArtistDao artistDao) {
|
||||
this.artistDao = artistDao;
|
||||
}
|
||||
|
||||
public void setAlbumDao(AlbumDao albumDao) {
|
||||
this.albumDao = albumDao;
|
||||
}
|
||||
|
||||
public void setMediaFileDao(MediaFileDao mediaFileDao) {
|
||||
this.mediaFileDao = mediaFileDao;
|
||||
}
|
||||
}
|
||||
+24
-19
@@ -19,29 +19,36 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
import org.libresonic.player.command.NetworkSettingsCommand;
|
||||
import org.libresonic.player.domain.UrlRedirectType;
|
||||
import org.libresonic.player.service.NetworkService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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 java.util.Random;
|
||||
|
||||
/**
|
||||
* Controller for the page used to change the network settings.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class NetworkSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/networkSettings")
|
||||
public class NetworkSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private NetworkService networkService;
|
||||
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(Model model) throws Exception {
|
||||
NetworkSettingsCommand command = new NetworkSettingsCommand();
|
||||
command.setPortForwardingEnabled(settingsService.isPortForwardingEnabled());
|
||||
command.setUrlRedirectionEnabled(settingsService.isUrlRedirectionEnabled());
|
||||
@@ -50,12 +57,16 @@ public class NetworkSettingsController extends SimpleFormController {
|
||||
command.setUrlRedirectCustomUrl(settingsService.getUrlRedirectCustomUrl());
|
||||
command.setPort(settingsService.getPort());
|
||||
command.setLicenseInfo(settingsService.getLicenseInfo());
|
||||
|
||||
return command;
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
|
||||
protected void doSubmitAction(Object cmd) throws Exception {
|
||||
NetworkSettingsCommand command = (NetworkSettingsCommand) cmd;
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "networkSettings";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") NetworkSettingsCommand command, Model model) throws Exception {
|
||||
command.setToast(true);
|
||||
|
||||
settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled());
|
||||
@@ -72,13 +83,7 @@ public class NetworkSettingsController extends SimpleFormController {
|
||||
settingsService.save();
|
||||
networkService.initPortForwarding(0);
|
||||
networkService.initUrlRedirection(true);
|
||||
return "networkSettings";
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setNetworkService(NetworkService networkService) {
|
||||
this.networkService = networkService;
|
||||
}
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
This file is part of Libresonic.
|
||||
|
||||
Libresonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libresonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors
|
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import org.springframework.web.servlet.mvc.*;
|
||||
import org.libresonic.player.service.*;
|
||||
import org.libresonic.player.command.*;
|
||||
import org.libresonic.player.domain.*;
|
||||
|
||||
import javax.servlet.http.*;
|
||||
|
||||
/**
|
||||
* Controller for the page used to change password.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PasswordSettingsController extends SimpleFormController {
|
||||
|
||||
private SecurityService securityService;
|
||||
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
PasswordSettingsCommand command = new PasswordSettingsCommand();
|
||||
User user = securityService.getCurrentUser(request);
|
||||
command.setUsername(user.getUsername());
|
||||
command.setLdapAuthenticated(user.isLdapAuthenticated());
|
||||
return command;
|
||||
}
|
||||
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
PasswordSettingsCommand command = (PasswordSettingsCommand) comm;
|
||||
User user = securityService.getUserByName(command.getUsername());
|
||||
user.setPassword(command.getPassword());
|
||||
securityService.updateUser(user);
|
||||
|
||||
command.setPassword(null);
|
||||
command.setConfirmPassword(null);
|
||||
command.setToast(true);
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
}
|
||||
+29
-26
@@ -19,35 +19,38 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
import org.libresonic.player.command.PersonalSettingsCommand;
|
||||
import org.libresonic.player.domain.AlbumListType;
|
||||
import org.libresonic.player.domain.AvatarScheme;
|
||||
import org.libresonic.player.domain.Theme;
|
||||
import org.libresonic.player.domain.User;
|
||||
import org.libresonic.player.domain.UserSettings;
|
||||
import org.libresonic.player.domain.*;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate per-user settings.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PersonalSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/personalSettings")
|
||||
public class PersonalSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
|
||||
@Override
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(HttpServletRequest request,Model model) throws Exception {
|
||||
PersonalSettingsCommand command = new PersonalSettingsCommand();
|
||||
|
||||
User user = securityService.getCurrentUser(request);
|
||||
@@ -100,12 +103,16 @@ public class PersonalSettingsController extends SimpleFormController {
|
||||
}
|
||||
}
|
||||
|
||||
return command;
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
PersonalSettingsCommand command = (PersonalSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "personalSettings";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") PersonalSettingsCommand command,Model model) throws Exception {
|
||||
|
||||
int localeIndex = Integer.parseInt(command.getLocaleIndex());
|
||||
Locale locale = null;
|
||||
@@ -152,6 +159,9 @@ public class PersonalSettingsController extends SimpleFormController {
|
||||
settingsService.updateUserSettings(settings);
|
||||
|
||||
command.setReloadNeeded(true);
|
||||
|
||||
model.addAttribute("command",command);
|
||||
return "personalSettings";
|
||||
}
|
||||
|
||||
private int getAvatarId(UserSettings userSettings) {
|
||||
@@ -178,11 +188,4 @@ public class PersonalSettingsController extends SimpleFormController {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
}
|
||||
|
||||
+28
-30
@@ -19,37 +19,46 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
import org.libresonic.player.command.PlayerSettingsCommand;
|
||||
import org.libresonic.player.domain.Player;
|
||||
import org.libresonic.player.domain.PlayerTechnology;
|
||||
import org.libresonic.player.domain.TranscodeScheme;
|
||||
import org.libresonic.player.domain.Transcoding;
|
||||
import org.libresonic.player.domain.User;
|
||||
import org.libresonic.player.domain.*;
|
||||
import org.libresonic.player.service.PlayerService;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.TranscodingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller for the player settings page.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PlayerSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/playerSettings")
|
||||
public class PlayerSettingsController {
|
||||
|
||||
@Autowired
|
||||
private PlayerService playerService;
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private TranscodingService transcodingService;
|
||||
|
||||
@Override
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "playerSettings";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(HttpServletRequest request, Model model) throws Exception {
|
||||
|
||||
handleRequestParameters(request);
|
||||
List<Player> players = getPlayers(request);
|
||||
@@ -91,12 +100,11 @@ public class PlayerSettingsController extends SimpleFormController {
|
||||
command.setPlayers(players.toArray(new Player[players.size()]));
|
||||
command.setAdmin(user.isAdminRole());
|
||||
|
||||
return command;
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
PlayerSettingsCommand command = (PlayerSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, Model model) throws Exception {
|
||||
Player player = playerService.getPlayerById(command.getPlayerId());
|
||||
|
||||
player.setAutoControlEnabled(command.isAutoControlEnabled());
|
||||
@@ -110,6 +118,7 @@ public class PlayerSettingsController extends SimpleFormController {
|
||||
transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds());
|
||||
|
||||
command.setReloadNeeded(true);
|
||||
return "redirect:playerSettings.view";
|
||||
}
|
||||
|
||||
private List<Player> getPlayers(HttpServletRequest request) {
|
||||
@@ -135,15 +144,4 @@ public class PlayerSettingsController extends SimpleFormController {
|
||||
}
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
|
||||
public void setPlayerService(PlayerService playerService) {
|
||||
this.playerService = playerService;
|
||||
}
|
||||
|
||||
public void setTranscodingService(TranscodingService transcodingService) {
|
||||
this.transcodingService = transcodingService;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-17
@@ -19,35 +19,45 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.libresonic.player.service.PodcastService;
|
||||
import org.libresonic.player.command.PodcastSettingsCommand;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.libresonic.player.service.PodcastService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Controller for the page used to administrate the Podcast receiver.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PodcastSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/podcastSettings")
|
||||
public class PodcastSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private PodcastService podcastService;
|
||||
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String formBackingObject(Model model) throws Exception {
|
||||
PodcastSettingsCommand command = new PodcastSettingsCommand();
|
||||
|
||||
command.setInterval(String.valueOf(settingsService.getPodcastUpdateInterval()));
|
||||
command.setEpisodeRetentionCount(String.valueOf(settingsService.getPodcastEpisodeRetentionCount()));
|
||||
command.setEpisodeDownloadCount(String.valueOf(settingsService.getPodcastEpisodeDownloadCount()));
|
||||
command.setFolder(settingsService.getPodcastFolder());
|
||||
return command;
|
||||
|
||||
model.addAttribute("command",command);
|
||||
return "podcastSettings";
|
||||
}
|
||||
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
PodcastSettingsCommand command = (PodcastSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute PodcastSettingsCommand command, Model model) throws Exception {
|
||||
command.setToast(true);
|
||||
|
||||
settingsService.setPodcastUpdateInterval(Integer.parseInt(command.getInterval()));
|
||||
@@ -57,13 +67,8 @@ public class PodcastSettingsController extends SimpleFormController {
|
||||
settingsService.save();
|
||||
|
||||
podcastService.schedule();
|
||||
model.addAttribute("command",command);
|
||||
return "podcastSettings";
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setPodcastService(PodcastService podcastService) {
|
||||
this.podcastService = podcastService;
|
||||
}
|
||||
}
|
||||
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
This file is part of Libresonic.
|
||||
|
||||
Libresonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libresonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors
|
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
import org.libresonic.player.command.PremiumSettingsCommand;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
|
||||
/**
|
||||
* Controller for the Subsonic Premium page.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PremiumSettingsController extends SimpleFormController {
|
||||
|
||||
private SettingsService settingsService;
|
||||
private SecurityService securityService;
|
||||
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
PremiumSettingsCommand command = new PremiumSettingsCommand();
|
||||
command.setPath(request.getParameter("path"));
|
||||
command.setForceChange(request.getParameter("change") != null);
|
||||
command.setLicenseInfo(settingsService.getLicenseInfo());
|
||||
command.setBrand(settingsService.getBrand());
|
||||
command.setUser(securityService.getCurrentUser(request));
|
||||
return command;
|
||||
}
|
||||
|
||||
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object com, BindException errors)
|
||||
throws Exception {
|
||||
PremiumSettingsCommand command = (PremiumSettingsCommand) com;
|
||||
Date now = new Date();
|
||||
|
||||
settingsService.setLicenseCode(command.getLicenseCode());
|
||||
settingsService.setLicenseEmail(command.getLicenseInfo().getLicenseEmail());
|
||||
settingsService.setLicenseDate(now);
|
||||
settingsService.save();
|
||||
settingsService.scheduleLicenseValidation();
|
||||
|
||||
// Reflect changes in view. The validator will validate the license asynchronously.
|
||||
command.setLicenseInfo(settingsService.getLicenseInfo());
|
||||
command.setToast(true);
|
||||
|
||||
return new ModelAndView(getSuccessView(), errors.getModel());
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
}
|
||||
+29
-37
@@ -19,50 +19,57 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
import org.libresonic.player.command.SearchCommand;
|
||||
import org.libresonic.player.domain.MusicFolder;
|
||||
import org.libresonic.player.domain.SearchCriteria;
|
||||
import org.libresonic.player.domain.SearchResult;
|
||||
import org.libresonic.player.domain.User;
|
||||
import org.libresonic.player.domain.UserSettings;
|
||||
import org.libresonic.player.domain.*;
|
||||
import org.libresonic.player.service.PlayerService;
|
||||
import org.libresonic.player.service.SearchService;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller for the search page.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class SearchController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/search")
|
||||
public class SearchController {
|
||||
|
||||
private static final int MATCH_COUNT = 25;
|
||||
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private PlayerService playerService;
|
||||
@Autowired
|
||||
private SearchService searchService;
|
||||
|
||||
@Override
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
return new SearchCommand();
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "search";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object com, BindException errors)
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(HttpServletRequest request, Model model) throws Exception {
|
||||
model.addAttribute("command",new SearchCommand());
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String onSubmit(HttpServletRequest request, HttpServletResponse response,@ModelAttribute("command") SearchCommand command, Model model)
|
||||
throws Exception {
|
||||
SearchCommand command = (SearchCommand) com;
|
||||
|
||||
User user = securityService.getCurrentUser(request);
|
||||
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
|
||||
@@ -90,22 +97,7 @@ public class SearchController extends SimpleFormController {
|
||||
command.setPlayer(playerService.getPlayer(request, response));
|
||||
}
|
||||
|
||||
return new ModelAndView(getSuccessView(), errors.getModel());
|
||||
return "search";
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setPlayerService(PlayerService playerService) {
|
||||
this.playerService = playerService;
|
||||
}
|
||||
|
||||
public void setSearchService(SearchService searchService) {
|
||||
this.searchService = searchService;
|
||||
}
|
||||
}
|
||||
|
||||
+34
-22
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.libresonic.player.command.UserSettingsCommand;
|
||||
import org.libresonic.player.domain.MusicFolder;
|
||||
import org.libresonic.player.domain.TranscodeScheme;
|
||||
@@ -28,14 +29,17 @@ import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.libresonic.player.service.TranscodingService;
|
||||
import org.libresonic.player.util.Util;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.libresonic.player.validator.UserSettingsValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.ServletRequestBindingException;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -45,14 +49,32 @@ import java.util.List;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class UserSettingsController extends SimpleFormController {
|
||||
@Controller
|
||||
@RequestMapping("/userSettings")
|
||||
@SessionAttributes(value = "command")
|
||||
public class UserSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private TranscodingService transcodingService;
|
||||
@Autowired
|
||||
private UserSettingsValidator userSettingsValidator;
|
||||
|
||||
@Override
|
||||
protected Object formBackingObject(HttpServletRequest request) throws Exception {
|
||||
@InitBinder
|
||||
protected void initBinder(WebDataBinder binder) {
|
||||
binder.addValidators(userSettingsValidator);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected String displayForm() throws Exception {
|
||||
return "userSettings";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
protected void formBackingObject(HttpServletRequest request,Model model) throws Exception {
|
||||
UserSettingsCommand command = new UserSettingsCommand();
|
||||
|
||||
User user = getUser(request);
|
||||
@@ -77,7 +99,7 @@ public class UserSettingsController extends SimpleFormController {
|
||||
command.setAllMusicFolders(settingsService.getAllMusicFolders());
|
||||
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
|
||||
|
||||
return command;
|
||||
model.addAttribute("command",command);
|
||||
}
|
||||
|
||||
private User getUser(HttpServletRequest request) throws ServletRequestBindingException {
|
||||
@@ -103,9 +125,8 @@ public class UserSettingsController extends SimpleFormController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
UserSettingsCommand command = (UserSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command) throws Exception {
|
||||
|
||||
if (command.isDeleteUser()) {
|
||||
deleteUser(command);
|
||||
@@ -115,6 +136,8 @@ public class UserSettingsController extends SimpleFormController {
|
||||
updateUser(command);
|
||||
}
|
||||
resetCommand(command);
|
||||
|
||||
return "userSettings";
|
||||
}
|
||||
|
||||
private void deleteUser(UserSettingsCommand command) {
|
||||
@@ -176,15 +199,4 @@ public class UserSettingsController extends SimpleFormController {
|
||||
command.setReload(true);
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setTranscodingService(TranscodingService transcodingService) {
|
||||
this.transcodingService = transcodingService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class RatingDao extends AbstractDao {
|
||||
*/
|
||||
public Integer getRatingForUser(String username, MediaFile mediaFile) {
|
||||
try {
|
||||
return getJdbcTemplate().queryForInt("select rating from user_rating where username=? and path=?", new Object[]{username, mediaFile.getPath()});
|
||||
return getJdbcTemplate().queryForObject("select rating from user_rating where username=? and path=?", new Object[]{username, mediaFile.getPath()},Integer.class);
|
||||
} catch (EmptyResultDataAccessException x) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class Schema {
|
||||
|
||||
protected boolean rowExists(JdbcTemplate template, String whereClause, String table) {
|
||||
try {
|
||||
int rowCount = template.queryForInt("select count(*) from " + table + " where " + whereClause);
|
||||
int rowCount = template.queryForObject("select count(*) from " + table + " where " + whereClause,Integer.class);
|
||||
return rowCount > 0;
|
||||
} catch (Exception x) {
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema26 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 2") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 2",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 2.");
|
||||
template.execute("insert into version values (2)");
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class Schema26 extends Schema {
|
||||
LOG.info("Database column 'player.dynamic_ip' was added successfully.");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from role where id = 6") == 0) {
|
||||
if (template.queryForObject("select count(*) from role where id = 6",Integer.class) == 0) {
|
||||
LOG.info("Role 'comment' not found in database. Creating it.");
|
||||
template.execute("insert into role values (6, 'comment')");
|
||||
template.execute("insert into user_role " +
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema27 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 3") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 3",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 3.");
|
||||
template.execute("insert into version values (3)");
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema28 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 4") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 4",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 4.");
|
||||
template.execute("insert into version values (4)");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema29 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 5") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 5",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 5.");
|
||||
template.execute("insert into version values (5)");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema30 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 6") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 6", Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 6.");
|
||||
template.execute("insert into version values (6)");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema31 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 7") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 7",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 7.");
|
||||
template.execute("insert into version values (7)");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Schema32 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 8") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 8",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 8.");
|
||||
template.execute("insert into version values (8)");
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class Schema32 extends Schema {
|
||||
LOG.info("Database table 'podcast_episode' was created successfully.");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from role where id = 7") == 0) {
|
||||
if (template.queryForObject("select count(*) from role where id = 7",Integer.class) == 0) {
|
||||
LOG.info("Role 'podcast' not found in database. Creating it.");
|
||||
template.execute("insert into role values (7, 'podcast')");
|
||||
template.execute("insert into user_role " +
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Schema33 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 9") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 9",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 9.");
|
||||
template.execute("insert into version values (9)");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Schema34 extends Schema {
|
||||
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 10") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 10",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 10.");
|
||||
template.execute("insert into version values (10)");
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Schema35 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 11") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 11",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 11.");
|
||||
template.execute("insert into version values (11)");
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class Schema35 extends Schema {
|
||||
LOG.info("Database column 'user_settings.web_player_default' was added successfully.");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from role where id = 8") == 0) {
|
||||
if (template.queryForObject("select count(*) from role where id = 8",Integer.class) == 0) {
|
||||
LOG.info("Role 'stream' not found in database. Creating it.");
|
||||
template.execute("insert into role values (8, 'stream')");
|
||||
template.execute("insert into user_role select distinct u.username, 8 from user u");
|
||||
@@ -135,7 +135,7 @@ public class Schema35 extends Schema {
|
||||
}
|
||||
|
||||
private void createAvatar(JdbcTemplate template, String avatar) {
|
||||
if (template.queryForInt("select count(*) from system_avatar where name = ?", new Object[]{avatar}) == 0) {
|
||||
if (template.queryForObject("select count(*) from system_avatar where name = ?", new Object[]{avatar},Integer.class) == 0) {
|
||||
|
||||
InputStream in = null;
|
||||
try {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema36 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 12") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 12",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 12.");
|
||||
template.execute("insert into version values (12)");
|
||||
}
|
||||
|
||||
@@ -37,19 +37,19 @@ public class Schema37 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 13") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 13",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 13.");
|
||||
template.execute("insert into version values (13)");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from role where id = 9") == 0) {
|
||||
if (template.queryForObject("select count(*) from role where id = 9",Integer.class) == 0) {
|
||||
LOG.info("Role 'settings' not found in database. Creating it.");
|
||||
template.execute("insert into role values (9, 'settings')");
|
||||
template.execute("insert into user_role select distinct u.username, 9 from user u");
|
||||
LOG.info("Role 'settings' was created successfully.");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from role where id = 10") == 0) {
|
||||
if (template.queryForObject("select count(*) from role where id = 10",Integer.class) == 0) {
|
||||
LOG.info("Role 'jukebox' not found in database. Creating it.");
|
||||
template.execute("insert into role values (10, 'jukebox')");
|
||||
template.execute("insert into user_role " +
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema38 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 14") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 14",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 14.");
|
||||
template.execute("insert into version values (14)");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema40 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 15") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 15",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 15.");
|
||||
template.execute("insert into version values (15)");
|
||||
|
||||
|
||||
@@ -40,12 +40,12 @@ public class Schema43 extends Schema {
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
// version 16 was used for 4.3.beta1
|
||||
if (template.queryForInt("select count(*) from version where version = 16") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 16",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 16.");
|
||||
template.execute("insert into version values (16)");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 17") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 17",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 17.");
|
||||
template.execute("insert into version values (17)");
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ public class Schema45 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 18") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 18",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 18.");
|
||||
template.execute("insert into version values (18)");
|
||||
}
|
||||
|
||||
if (template.queryForInt("select count(*) from role where id = 11") == 0) {
|
||||
if (template.queryForObject("select count(*) from role where id = 11",Integer.class) == 0) {
|
||||
LOG.info("Role 'share' not found in database. Creating it.");
|
||||
template.execute("insert into role values (11, 'share')");
|
||||
template.execute("insert into user_role " +
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema46 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 19") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 19",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 19.");
|
||||
template.execute("insert into version values (19)");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema47 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 20") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 20",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 20.");
|
||||
template.execute("insert into version values (20)");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema49 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 21") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 21",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 21.");
|
||||
template.execute("insert into version values (21)");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Schema50 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 22") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 22",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 22.");
|
||||
template.execute("insert into version values (22)");
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Schema50 extends Schema {
|
||||
}
|
||||
|
||||
// Added in 5.0.beta2
|
||||
if (template.queryForInt("select count(*) from version where version = 23") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 23",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 23.");
|
||||
template.execute("insert into version values (23)");
|
||||
template.execute("update transcoding2 set step1='ffmpeg -i %s -map 0:0 -b:a %bk -v 0 -f mp3 -' where name='mp3 audio'");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Schema51 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 23") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 23",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 23.");
|
||||
template.execute("insert into version values (23)");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Schema52 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 24") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 24",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 24.");
|
||||
template.execute("insert into version values (24)");
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Schema53 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 25") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 25",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 25.");
|
||||
template.execute("insert into version values (25)");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Schema61 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 26") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 26",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 26.");
|
||||
template.execute("insert into version values (26)");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Schema62 extends Schema {
|
||||
@Override
|
||||
public void execute(JdbcTemplate template) {
|
||||
|
||||
if (template.queryForInt("select count(*) from version where version = 27") == 0) {
|
||||
if (template.queryForObject("select count(*) from version where version = 27",Integer.class) == 0) {
|
||||
LOG.info("Updating database schema to version 27.");
|
||||
template.execute("insert into version values (27)");
|
||||
}
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
This file is part of Libresonic.
|
||||
|
||||
Libresonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libresonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors
|
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
|
||||
*/
|
||||
package org.libresonic.player.validator;
|
||||
|
||||
import org.springframework.validation.*;
|
||||
import org.libresonic.player.command.*;
|
||||
import org.libresonic.player.controller.*;
|
||||
|
||||
/**
|
||||
* Validator for {@link PasswordSettingsController}.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PasswordSettingsValidator implements Validator {
|
||||
|
||||
public boolean supports(Class clazz) {
|
||||
return clazz.equals(PasswordSettingsCommand.class);
|
||||
}
|
||||
|
||||
public void validate(Object obj, Errors errors) {
|
||||
PasswordSettingsCommand command = (PasswordSettingsCommand) obj;
|
||||
|
||||
if (command.getPassword() == null || command.getPassword().length() == 0) {
|
||||
errors.rejectValue("password", "usersettings.nopassword");
|
||||
} else if (!command.getPassword().equals(command.getConfirmPassword())) {
|
||||
errors.rejectValue("password", "usersettings.wrongpassword");
|
||||
}
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
This file is part of Libresonic.
|
||||
|
||||
Libresonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libresonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2016 (C) Libresonic Authors
|
||||
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
|
||||
*/
|
||||
package org.libresonic.player.validator;
|
||||
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
import org.libresonic.player.command.PremiumSettingsCommand;
|
||||
import org.libresonic.player.controller.PremiumSettingsController;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
|
||||
/**
|
||||
* Validator for {@link PremiumSettingsController}.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class PremiumSettingsValidator implements Validator {
|
||||
private SettingsService settingsService;
|
||||
|
||||
public boolean supports(Class clazz) {
|
||||
return clazz.equals(PremiumSettingsCommand.class);
|
||||
}
|
||||
|
||||
public void validate(Object obj, Errors errors) {
|
||||
PremiumSettingsCommand command = (PremiumSettingsCommand) obj;
|
||||
|
||||
if (!settingsService.isLicenseValid(command.getLicenseInfo().getLicenseEmail(), command.getLicenseCode())) {
|
||||
command.setSubmissionError(true);
|
||||
errors.rejectValue("licenseCode", "premium.invalidlicense");
|
||||
}
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
}
|
||||
+5
-7
@@ -24,6 +24,8 @@ import org.libresonic.player.controller.UserSettingsController;
|
||||
import org.libresonic.player.service.SecurityService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
@@ -32,9 +34,12 @@ import org.springframework.validation.Validator;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
@Component
|
||||
public class UserSettingsValidator implements Validator {
|
||||
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
/**
|
||||
@@ -82,11 +87,4 @@ public class UserSettingsValidator implements Validator {
|
||||
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
|
||||
http://www.springframework.org/schema/security/spring-security.xsd">
|
||||
|
||||
<security:http auto-config='true'>
|
||||
<!-- IS_AUTHENTICATED_ANONYMOUSLY -->
|
||||
|
||||
@@ -2,7 +2,18 @@
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/mvc
|
||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<mvc:annotation-driven />
|
||||
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/>
|
||||
|
||||
<bean id="leftController" class="org.libresonic.player.controller.LeftController">
|
||||
<property name="viewName" value="left"/>
|
||||
@@ -150,26 +161,9 @@
|
||||
<property name="mediaFileDao" ref="mediaFileDao"/>
|
||||
<property name="mediaFileService" ref="mediaFileService"/>
|
||||
</bean>
|
||||
<bean id="searchController" class="org.libresonic.player.controller.SearchController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.SearchCommand"/>
|
||||
<property name="successView" value="search"/>
|
||||
<property name="formView" value="search"/>
|
||||
<property name="searchService" ref="searchService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="playerService" ref="playerService"/>
|
||||
</bean>
|
||||
<bean id="settingsController" class="org.libresonic.player.controller.SettingsController">
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="playerSettingsController" class="org.libresonic.player.controller.PlayerSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.PlayerSettingsCommand"/>
|
||||
<property name="successView" value="playerSettings"/>
|
||||
<property name="formView" value="playerSettings"/>
|
||||
<property name="playerService" ref="playerService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="transcodingService" ref="transcodingService"/>
|
||||
</bean>
|
||||
<bean id="dlnaSettingsController" class="org.libresonic.player.controller.DLNASettingsController">
|
||||
<property name="viewName" value="dlnaSettings"/>
|
||||
<property name="upnpService" ref="upnpService"/>
|
||||
@@ -187,23 +181,6 @@
|
||||
<property name="mediaFileService" ref="mediaFileService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="musicFolderSettingsController" class="org.libresonic.player.controller.MusicFolderSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.MusicFolderSettingsCommand"/>
|
||||
<property name="successView" value="musicFolderSettings"/>
|
||||
<property name="formView" value="musicFolderSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="mediaScannerService" ref="mediaScannerService"/>
|
||||
<property name="artistDao" ref="artistDao"/>
|
||||
<property name="albumDao" ref="albumDao"/>
|
||||
<property name="mediaFileDao" ref="mediaFileDao"/>
|
||||
</bean>
|
||||
<bean id="networkSettingsController" class="org.libresonic.player.controller.NetworkSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.NetworkSettingsCommand"/>
|
||||
<property name="successView" value="networkSettings"/>
|
||||
<property name="formView" value="networkSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="networkService" ref="networkService"/>
|
||||
</bean>
|
||||
<bean id="transcodingSettingsController" class="org.libresonic.player.controller.TranscodingSettingsController">
|
||||
<property name="viewName" value="transcodingSettings"/>
|
||||
<property name="transcodingService" ref="transcodingService"/>
|
||||
@@ -214,55 +191,11 @@
|
||||
<property name="viewName" value="internetRadioSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="podcastSettingsController" class="org.libresonic.player.controller.PodcastSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.PodcastSettingsCommand"/>
|
||||
<property name="successView" value="podcastSettings"/>
|
||||
<property name="formView" value="podcastSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="podcastService" ref="podcastService"/>
|
||||
</bean>
|
||||
<bean id="generalSettingsController" class="org.libresonic.player.controller.GeneralSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.GeneralSettingsCommand"/>
|
||||
<property name="successView" value="generalSettings"/>
|
||||
<property name="formView" value="generalSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="advancedSettingsController" class="org.libresonic.player.controller.AdvancedSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.AdvancedSettingsCommand"/>
|
||||
<property name="successView" value="advancedSettings"/>
|
||||
<property name="formView" value="advancedSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="personalSettingsController" class="org.libresonic.player.controller.PersonalSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.PersonalSettingsCommand"/>
|
||||
<property name="successView" value="personalSettings"/>
|
||||
<property name="formView" value="personalSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="avatarUploadController" class="org.libresonic.player.controller.AvatarUploadController">
|
||||
<property name="viewName" value="avatarUploadResult"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="userSettingsController" class="org.libresonic.player.controller.UserSettingsController">
|
||||
<property name="sessionForm" value="true"/>
|
||||
<property name="commandClass" value="org.libresonic.player.command.UserSettingsCommand"/>
|
||||
<property name="validator" ref="userSettingsValidator"/>
|
||||
<property name="successView" value="userSettings"/>
|
||||
<property name="formView" value="userSettings"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="transcodingService" ref="transcodingService"/>
|
||||
</bean>
|
||||
<bean id="passwordSettingsController" class="org.libresonic.player.controller.PasswordSettingsController">
|
||||
<property name="sessionForm" value="true"/>
|
||||
<property name="commandClass" value="org.libresonic.player.command.PasswordSettingsCommand"/>
|
||||
<property name="validator" ref="passwordSettingsValidator"/>
|
||||
<property name="successView" value="passwordSettings"/>
|
||||
<property name="formView" value="passwordSettings"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="homeController" class="org.libresonic.player.controller.HomeController">
|
||||
<property name="viewName" value="home"/>
|
||||
<property name="ratingService" ref="ratingService"/>
|
||||
@@ -345,14 +278,6 @@
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="mediaFileService" ref="mediaFileService"/>
|
||||
</bean>
|
||||
<bean id="premiumSettingsController" class="org.libresonic.player.controller.PremiumSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.PremiumSettingsCommand"/>
|
||||
<property name="successView" value="premiumSettings"/>
|
||||
<property name="formView" value="premiumSettings"/>
|
||||
<property name="validator" ref="premiumSettingsValidator"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="multiController" class="org.libresonic.player.controller.MultiController">
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
@@ -403,14 +328,6 @@
|
||||
<property name="viewName" value="db"/>
|
||||
<property name="daoHelper" ref="daoHelper"/>
|
||||
</bean>
|
||||
<bean id="premiumSettingsValidator" class="org.libresonic.player.validator.PremiumSettingsValidator">
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="userSettingsValidator" class="org.libresonic.player.validator.UserSettingsValidator">
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="passwordSettingsValidator" class="org.libresonic.player.validator.PasswordSettingsValidator"/>
|
||||
|
||||
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
||||
<property name="alwaysUseFullPath" value="true"/>
|
||||
@@ -434,7 +351,10 @@
|
||||
<prop key="/top.view">topController</prop>
|
||||
<prop key="/randomPlayQueue.view">randomPlayQueueController</prop>
|
||||
<prop key="/changeCoverArt.view">changeCoverArtController</prop>
|
||||
<!--
|
||||
login.view has moved to the LoginController
|
||||
<prop key="/login.view">multiController</prop>
|
||||
-->
|
||||
<prop key="/recover.view">multiController</prop>
|
||||
<prop key="/accessDenied.view">multiController</prop>
|
||||
<prop key="/notFound.view">multiController</prop>
|
||||
@@ -443,24 +363,13 @@
|
||||
<prop key="/videoPlayer.view">videoPlayerController</prop>
|
||||
<prop key="/nowPlaying.view">nowPlayingController</prop>
|
||||
<prop key="/starred.view">starredController</prop>
|
||||
<prop key="/search.view">searchController</prop>
|
||||
<prop key="/settings.view">settingsController</prop>
|
||||
<prop key="/playerSettings.view">playerSettingsController</prop>
|
||||
<prop key="/dlnaSettings.view">dlnaSettingsController</prop>
|
||||
<prop key="/sonosSettings.view">sonosSettingsController</prop>
|
||||
<prop key="/shareSettings.view">shareSettingsController</prop>
|
||||
<prop key="/musicFolderSettings.view">musicFolderSettingsController</prop>
|
||||
<prop key="/networkSettings.view">networkSettingsController</prop>
|
||||
<prop key="/transcodingSettings.view">transcodingSettingsController</prop>
|
||||
<prop key="/internetRadioSettings.view">internetRadioSettingsController</prop>
|
||||
<prop key="/podcastSettings.view">podcastSettingsController</prop>
|
||||
<prop key="/generalSettings.view">generalSettingsController</prop>
|
||||
<prop key="/advancedSettings.view">advancedSettingsController</prop>
|
||||
<prop key="/personalSettings.view">personalSettingsController</prop>
|
||||
<prop key="/avatarUpload.view">avatarUploadController</prop>
|
||||
<prop key="/userSettings.view">userSettingsController</prop>
|
||||
<prop key="/passwordSettings.view">passwordSettingsController</prop>
|
||||
<prop key="/premiumSettings.view">premiumSettingsController</prop>
|
||||
<prop key="/allmusic.view">allmusicController</prop>
|
||||
<prop key="/home.view">homeController</prop>
|
||||
<prop key="/editTags.view">editTagsController</prop>
|
||||
|
||||
@@ -88,7 +88,7 @@ public class TestCaseUtils {
|
||||
* @return
|
||||
*/
|
||||
public static Integer recordsInTable(String tableName, DaoHelper daoHelper) {
|
||||
return daoHelper.getJdbcTemplate().queryForInt("select count(1) from " + tableName);
|
||||
return daoHelper.getJdbcTemplate().queryForObject("select count(1) from " + tableName,Integer.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user