Migration of GeneralSettingsController + unit test.
This commit is contained in:
+18
-9
@@ -23,6 +23,12 @@ import java.util.Locale;
|
||||
|
||||
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.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.libresonic.player.command.GeneralSettingsCommand;
|
||||
@@ -34,11 +40,15 @@ import org.libresonic.player.service.SettingsService;
|
||||
*
|
||||
* @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 formBackingObject(Model model) throws Exception {
|
||||
GeneralSettingsCommand command = new GeneralSettingsCommand();
|
||||
command.setCoverArtFileTypes(settingsService.getCoverArtFileTypes());
|
||||
command.setIgnoredArticles(settingsService.getIgnoredArticles());
|
||||
@@ -76,12 +86,12 @@ public class GeneralSettingsController extends SimpleFormController {
|
||||
}
|
||||
command.setLocales(localeStrings);
|
||||
|
||||
return command;
|
||||
|
||||
model.addAttribute("command",command);
|
||||
return "generalSettings";
|
||||
}
|
||||
|
||||
protected void doSubmitAction(Object comm) throws Exception {
|
||||
GeneralSettingsCommand command = (GeneralSettingsCommand) comm;
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
protected String doSubmitAction(@ModelAttribute 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,12 +208,6 @@
|
||||
<property name="viewName" value="internetRadioSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</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="personalSettingsController" class="org.libresonic.player.controller.PersonalSettingsController">
|
||||
<property name="commandClass" value="org.libresonic.player.command.PersonalSettingsCommand"/>
|
||||
<property name="successView" value="personalSettings"/>
|
||||
@@ -435,7 +429,6 @@
|
||||
<prop key="/shareSettings.view">shareSettingsController</prop>
|
||||
<prop key="/transcodingSettings.view">transcodingSettingsController</prop>
|
||||
<prop key="/internetRadioSettings.view">internetRadioSettingsController</prop>
|
||||
<prop key="/generalSettings.view">generalSettingsController</prop>
|
||||
<prop key="/personalSettings.view">personalSettingsController</prop>
|
||||
<prop key="/avatarUpload.view">avatarUploadController</prop>
|
||||
<prop key="/userSettings.view">userSettingsController</prop>
|
||||
|
||||
Reference in New Issue
Block a user