Controller migration

master
Rémi Cocula 8 years ago
parent 376f98d670
commit f76470537f
  1. 20
      libresonic-main/src/main/java/org/libresonic/player/controller/DBController.java
  2. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/ExternalPlayerController.java
  3. 13
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -19,12 +19,15 @@
*/
package org.libresonic.player.controller;
import org.libresonic.player.dao.DaoHelper;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.libresonic.player.dao.DaoHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ColumnMapRowMapper;
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.mvc.ParameterizableViewController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -37,10 +40,14 @@ import java.util.Map;
*
* @author Sindre Mehus
*/
public class DBController extends ParameterizableViewController {
@Controller
@RequestMapping("/db")
public class DBController {
@Autowired
private DaoHelper daoHelper;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
@ -56,12 +63,7 @@ public class DBController extends ParameterizableViewController {
}
}
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("db","model",map);
}
public void setDaoHelper(DaoHelper daoHelper) {
this.daoHelper = daoHelper;
}
}

@ -19,19 +19,6 @@
*/
package org.libresonic.player.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.Player;
@ -40,20 +27,36 @@ import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.ShareService;
import org.springframework.beans.factory.annotation.Autowired;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* Controller for the page used to play shared music (Twitter, Facebook etc).
*
* @author Sindre Mehus
*/
public class ExternalPlayerController extends ParameterizableViewController {
@Controller
@RequestMapping("/share/**")
public class ExternalPlayerController {
@Autowired
private SettingsService settingsService;
@Autowired
private PlayerService playerService;
@Autowired
private ShareService shareService;
@Autowired
private MediaFileService mediaFileService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
@ -84,9 +87,7 @@ public class ExternalPlayerController extends ParameterizableViewController {
map.put("redirectUrl", settingsService.getUrlRedirectUrl());
map.put("player", player.getId());
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("externalPlayer", "model", map);
}
private List<MediaFile> getSongs(Share share, String username) throws IOException {
@ -108,19 +109,4 @@ public class ExternalPlayerController extends ParameterizableViewController {
return result;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setShareService(ShareService shareService) {
this.shareService = shareService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -17,13 +17,6 @@
org.libresonic.player.validator,
org.libresonic.player.security"/>
<bean id="externalPlayerController" class="org.libresonic.player.controller.ExternalPlayerController">
<property name="viewName" value="externalPlayer"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="settingsService" ref="settingsService"/>
<property name="playerService" ref="playerService"/>
<property name="shareService" ref="shareService"/>
</bean>
<bean id="wapController" class="org.libresonic.player.controller.WapController">
<property name="settingsService" ref="settingsService"/>
<property name="playerService" ref="playerService"/>
@ -65,21 +58,15 @@
<property name="userSettingsController" ref="userSettingsController"/>
<property name="leftController" ref="leftController"/>
</bean>
<bean id="dbController" class="org.libresonic.player.controller.DBController">
<property name="viewName" value="db"/>
<property name="daoHelper" ref="daoHelper"/>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
<prop key="/db.view">dbController</prop>
<prop key="/podcast/**">podcastController</prop>
<prop key="/wap/download.view">downloadController</prop>
<prop key="/wap/**">wapController</prop>
<prop key="/rest/**">restController</prop>
<prop key="/share/**">externalPlayerController</prop>
</props>
</property>
</bean>

Loading…
Cancel
Save