|
|
@ -25,6 +25,12 @@ import java.util.Locale; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
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.ModelAttribute; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
import org.springframework.web.servlet.mvc.SimpleFormController; |
|
|
|
import org.springframework.web.servlet.mvc.SimpleFormController; |
|
|
|
|
|
|
|
|
|
|
|
import org.libresonic.player.command.PersonalSettingsCommand; |
|
|
|
import org.libresonic.player.command.PersonalSettingsCommand; |
|
|
@ -41,13 +47,17 @@ import org.libresonic.player.service.SettingsService; |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Sindre Mehus |
|
|
|
* @author Sindre Mehus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class PersonalSettingsController extends SimpleFormController { |
|
|
|
@Controller |
|
|
|
|
|
|
|
@RequestMapping("/personalSettings") |
|
|
|
|
|
|
|
public class PersonalSettingsController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SettingsService settingsService; |
|
|
|
private SettingsService settingsService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SecurityService securityService; |
|
|
|
private SecurityService securityService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ModelAttribute |
|
|
|
protected Object formBackingObject(HttpServletRequest request) throws Exception { |
|
|
|
protected void formBackingObject(HttpServletRequest request,Model model) throws Exception { |
|
|
|
PersonalSettingsCommand command = new PersonalSettingsCommand(); |
|
|
|
PersonalSettingsCommand command = new PersonalSettingsCommand(); |
|
|
|
|
|
|
|
|
|
|
|
User user = securityService.getCurrentUser(request); |
|
|
|
User user = securityService.getCurrentUser(request); |
|
|
@ -100,12 +110,16 @@ public class PersonalSettingsController extends SimpleFormController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return command; |
|
|
|
model.addAttribute("command",command); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@RequestMapping(method = RequestMethod.GET) |
|
|
|
protected void doSubmitAction(Object comm) throws Exception { |
|
|
|
protected String displayForm() throws Exception { |
|
|
|
PersonalSettingsCommand command = (PersonalSettingsCommand) comm; |
|
|
|
return "personalSettings"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST) |
|
|
|
|
|
|
|
protected String doSubmitAction(@ModelAttribute("command") PersonalSettingsCommand command,Model model) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
int localeIndex = Integer.parseInt(command.getLocaleIndex()); |
|
|
|
int localeIndex = Integer.parseInt(command.getLocaleIndex()); |
|
|
|
Locale locale = null; |
|
|
|
Locale locale = null; |
|
|
@ -152,6 +166,9 @@ public class PersonalSettingsController extends SimpleFormController { |
|
|
|
settingsService.updateUserSettings(settings); |
|
|
|
settingsService.updateUserSettings(settings); |
|
|
|
|
|
|
|
|
|
|
|
command.setReloadNeeded(true); |
|
|
|
command.setReloadNeeded(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.addAttribute("command",command); |
|
|
|
|
|
|
|
return "personalSettings"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int getAvatarId(UserSettings userSettings) { |
|
|
|
private int getAvatarId(UserSettings userSettings) { |
|
|
@ -178,11 +195,4 @@ public class PersonalSettingsController extends SimpleFormController { |
|
|
|
return avatarId; |
|
|
|
return avatarId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setSettingsService(SettingsService settingsService) { |
|
|
|
|
|
|
|
this.settingsService = settingsService; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setSecurityService(SecurityService securityService) { |
|
|
|
|
|
|
|
this.securityService = securityService; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|