|
|
@ -25,7 +25,12 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
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.validation.BindException; |
|
|
|
import org.springframework.validation.BindException; |
|
|
|
|
|
|
|
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.ModelAndView; |
|
|
|
import org.springframework.web.servlet.mvc.SimpleFormController; |
|
|
|
import org.springframework.web.servlet.mvc.SimpleFormController; |
|
|
|
|
|
|
|
|
|
|
@ -45,24 +50,30 @@ import org.libresonic.player.service.SettingsService; |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Sindre Mehus |
|
|
|
* @author Sindre Mehus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class SearchController extends SimpleFormController { |
|
|
|
@Controller |
|
|
|
|
|
|
|
@RequestMapping("/search") |
|
|
|
|
|
|
|
public class SearchController { |
|
|
|
|
|
|
|
|
|
|
|
private static final int MATCH_COUNT = 25; |
|
|
|
private static final int MATCH_COUNT = 25; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SecurityService securityService; |
|
|
|
private SecurityService securityService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SettingsService settingsService; |
|
|
|
private SettingsService settingsService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PlayerService playerService; |
|
|
|
private PlayerService playerService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SearchService searchService; |
|
|
|
private SearchService searchService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@RequestMapping(method = RequestMethod.GET) |
|
|
|
protected Object formBackingObject(HttpServletRequest request) throws Exception { |
|
|
|
protected String formBackingObject(HttpServletRequest request, Model model) throws Exception { |
|
|
|
return new SearchCommand(); |
|
|
|
model.addAttribute("command",new SearchCommand()); |
|
|
|
|
|
|
|
return "search"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@RequestMapping(method = RequestMethod.POST) |
|
|
|
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object com, BindException errors) |
|
|
|
protected String onSubmit(HttpServletRequest request, HttpServletResponse response, SearchCommand command, Model model) |
|
|
|
throws Exception { |
|
|
|
throws Exception { |
|
|
|
SearchCommand command = (SearchCommand) com; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User user = securityService.getCurrentUser(request); |
|
|
|
User user = securityService.getCurrentUser(request); |
|
|
|
UserSettings userSettings = settingsService.getUserSettings(user.getUsername()); |
|
|
|
UserSettings userSettings = settingsService.getUserSettings(user.getUsername()); |
|
|
@ -90,22 +101,8 @@ public class SearchController extends SimpleFormController { |
|
|
|
command.setPlayer(playerService.getPlayer(request, response)); |
|
|
|
command.setPlayer(playerService.getPlayer(request, response)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new ModelAndView(getSuccessView(), errors.getModel()); |
|
|
|
model.addAttribute("command",command); |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|