Small refactor on httpservletrequest injection

master
Andrew DeMaria 5 years ago
parent a9b4d481c3
commit 42bced139f
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 6
      airsonic-main/src/main/java/org/airsonic/player/controller/UserSettingsController.java
  2. 12
      airsonic-main/src/main/java/org/airsonic/player/validator/UserSettingsValidator.java

@ -66,12 +66,10 @@ public class UserSettingsController {
private SettingsService settingsService;
@Autowired
private TranscodingService transcodingService;
@Autowired
private UserSettingsValidator userSettingsValidator;
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.addValidators(userSettingsValidator);
protected void initBinder(WebDataBinder binder, HttpServletRequest request) {
binder.addValidators(new UserSettingsValidator(securityService, settingsService, request));
}
@GetMapping

@ -24,8 +24,6 @@ import org.airsonic.player.controller.UserSettingsController;
import org.airsonic.player.service.SecurityService;
import org.airsonic.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;
@ -36,16 +34,18 @@ import javax.servlet.http.HttpServletRequest;
*
* @author Sindre Mehus
*/
@Component
public class UserSettingsValidator implements Validator {
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
@Autowired
private HttpServletRequest request;
public UserSettingsValidator(SecurityService securityService, SettingsService settingsService, HttpServletRequest request) {
this.securityService = securityService;
this.settingsService = settingsService;
this.request = request;
}
/**
* {@inheritDoc}
*/

Loading…
Cancel
Save