Controllers migration.
This commit is contained in:
+11
-11
@@ -30,6 +30,10 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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 org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
@@ -50,15 +54,19 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class AvatarUploadController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/avatarUpload")
|
||||
public class AvatarUploadController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(AvatarUploadController.class);
|
||||
private static final int MAX_AVATAR_SIZE = 64;
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
|
||||
@Override
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
String username = securityService.getCurrentUsername(request);
|
||||
@@ -93,9 +101,7 @@ public class AvatarUploadController extends ParameterizableViewController {
|
||||
|
||||
map.put("username", username);
|
||||
map.put("avatar", settingsService.getCustomAvatar(username));
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("avatarUploadResult","model",map);
|
||||
}
|
||||
|
||||
private void createAvatar(String fileName, byte[] data, String username, Map<String, Object> map) throws IOException {
|
||||
@@ -132,11 +138,5 @@ public class AvatarUploadController extends ParameterizableViewController {
|
||||
}
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -25,7 +25,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
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;
|
||||
|
||||
@@ -37,12 +41,16 @@ import org.libresonic.player.service.UPnPService;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class DLNASettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/dlnaSettings")
|
||||
public class DLNASettingsController {
|
||||
|
||||
@Autowired
|
||||
private UPnPService upnpService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -52,13 +60,11 @@ public class DLNASettingsController extends ParameterizableViewController {
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("dlnaEnabled", settingsService.isDlnaEnabled());
|
||||
map.put("dlnaServerName", settingsService.getDlnaServerName());
|
||||
map.put("licenseInfo", settingsService.getLicenseInfo());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("dlnaSettings","model",map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,11 +91,5 @@ public class DLNASettingsController extends ParameterizableViewController {
|
||||
upnpService.setMediaServerEnabled(dlnaEnabled);
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setUpnpService(UPnPService upnpService) {
|
||||
this.upnpService = upnpService;
|
||||
}
|
||||
}
|
||||
+20
-23
@@ -19,35 +19,41 @@
|
||||
*/
|
||||
package org.libresonic.player.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
import org.libresonic.player.domain.MediaFile;
|
||||
import org.libresonic.player.service.MediaFileService;
|
||||
import org.libresonic.player.service.metadata.JaudiotaggerParser;
|
||||
import org.libresonic.player.service.metadata.MetaDataParser;
|
||||
import org.libresonic.player.service.metadata.MetaDataParserFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
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.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controller for the page used to edit MP3 tags.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class EditTagsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/editTags")
|
||||
public class EditTagsController {
|
||||
|
||||
@Autowired
|
||||
private MetaDataParserFactory metaDataParserFactory;
|
||||
@Autowired
|
||||
private MediaFileService mediaFileService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
|
||||
@@ -70,9 +76,7 @@ public class EditTagsController extends ParameterizableViewController {
|
||||
map.put("id", id);
|
||||
map.put("songs", songs);
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("editTags","model",map);
|
||||
}
|
||||
|
||||
private Song createSong(MediaFile file, int index) {
|
||||
@@ -92,13 +96,6 @@ public class EditTagsController extends ParameterizableViewController {
|
||||
return song;
|
||||
}
|
||||
|
||||
public void setMetaDataParserFactory(MetaDataParserFactory metaDataParserFactory) {
|
||||
this.metaDataParserFactory = metaDataParserFactory;
|
||||
}
|
||||
|
||||
public void setMediaFileService(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains information about a single song.
|
||||
|
||||
+10
-9
@@ -22,6 +22,10 @@ package org.libresonic.player.controller;
|
||||
import org.libresonic.player.domain.InternetRadio;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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 org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
@@ -37,11 +41,14 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class InternetRadioSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/internetRadioSettings")
|
||||
public class InternetRadioSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -54,11 +61,8 @@ public class InternetRadioSettingsController extends ParameterizableViewControll
|
||||
}
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("internetRadios", settingsService.getAllInternetRadios(true));
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("internetRadioSettings","model",map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +120,5 @@ public class InternetRadioSettingsController extends ParameterizableViewControll
|
||||
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-20
@@ -30,7 +30,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
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;
|
||||
|
||||
@@ -48,14 +52,20 @@ import org.libresonic.player.service.ShareService;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class ShareSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/shareSettings")
|
||||
public class ShareSettingsController {
|
||||
|
||||
@Autowired
|
||||
private ShareService shareService;
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
@Autowired
|
||||
private MediaFileService mediaFileService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -65,14 +75,12 @@ public class ShareSettingsController extends ParameterizableViewController {
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("shareBaseUrl", shareService.getShareBaseUrl());
|
||||
map.put("shareInfos", getShareInfos(request));
|
||||
map.put("user", securityService.getCurrentUser(request));
|
||||
map.put("licenseInfo", settingsService.getLicenseInfo());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("shareSettings","model",map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,21 +156,6 @@ public class ShareSettingsController extends ParameterizableViewController {
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public void setSecurityService(SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
|
||||
public void setShareService(ShareService shareService) {
|
||||
this.shareService = shareService;
|
||||
}
|
||||
|
||||
public void setMediaFileService(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public static class ShareInfo {
|
||||
private final Share share;
|
||||
|
||||
+11
-12
@@ -25,7 +25,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.ServletRequestUtils;
|
||||
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;
|
||||
|
||||
@@ -37,12 +41,16 @@ import org.libresonic.player.service.SonosService;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class SonosSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/sonosSettings")
|
||||
public class SonosSettingsController {
|
||||
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
@Autowired
|
||||
private SonosService sonosService;
|
||||
|
||||
@Override
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -52,13 +60,11 @@ public class SonosSettingsController extends ParameterizableViewController {
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("sonosEnabled", settingsService.isSonosEnabled());
|
||||
map.put("sonosServiceName", settingsService.getSonosServiceName());
|
||||
map.put("licenseInfo", settingsService.getLicenseInfo());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("sonosSettings","model",map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,11 +92,4 @@ public class SonosSettingsController extends ParameterizableViewController {
|
||||
sonosService.setMusicServiceEnabled(sonosEnabled);
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
public void setSonosService(SonosService sonosService) {
|
||||
this.sonosService = sonosService;
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -23,6 +23,10 @@ import org.libresonic.player.domain.Transcoding;
|
||||
import org.libresonic.player.service.TranscodingService;
|
||||
import org.libresonic.player.service.SettingsService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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 org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
@@ -36,12 +40,16 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
public class TranscodingSettingsController extends ParameterizableViewController {
|
||||
@Controller
|
||||
@RequestMapping("/transcodingSettings")
|
||||
public class TranscodingSettingsController {
|
||||
|
||||
@Autowired
|
||||
private TranscodingService transcodingService;
|
||||
@Autowired
|
||||
private SettingsService settingsService;
|
||||
|
||||
@Override
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -51,15 +59,13 @@ public class TranscodingSettingsController extends ParameterizableViewController
|
||||
map.put("toast", true);
|
||||
}
|
||||
|
||||
ModelAndView result = super.handleRequestInternal(request, response);
|
||||
map.put("transcodings", transcodingService.getAllTranscodings());
|
||||
map.put("transcodeDirectory", transcodingService.getTranscodeDirectory());
|
||||
map.put("downsampleCommand", settingsService.getDownsamplingCommand());
|
||||
map.put("hlsCommand", settingsService.getHlsCommand());
|
||||
map.put("brand", settingsService.getBrand());
|
||||
|
||||
result.addObject("model", map);
|
||||
return result;
|
||||
return new ModelAndView("transcodingSettings","model",map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,11 +142,4 @@ public class TranscodingSettingsController extends ParameterizableViewController
|
||||
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
|
||||
}
|
||||
|
||||
public void setTranscodingService(TranscodingService transcodingService) {
|
||||
this.transcodingService = transcodingService;
|
||||
}
|
||||
|
||||
public void setSettingsService(SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,43 +15,6 @@
|
||||
<mvc:annotation-driven />
|
||||
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/>
|
||||
|
||||
<bean id="dlnaSettingsController" class="org.libresonic.player.controller.DLNASettingsController">
|
||||
<property name="viewName" value="dlnaSettings"/>
|
||||
<property name="upnpService" ref="upnpService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="sonosSettingsController" class="org.libresonic.player.controller.SonosSettingsController">
|
||||
<property name="viewName" value="sonosSettings"/>
|
||||
<property name="sonosService" ref="sonosService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="shareSettingsController" class="org.libresonic.player.controller.ShareSettingsController">
|
||||
<property name="viewName" value="shareSettings"/>
|
||||
<property name="shareService" ref="shareService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
<property name="mediaFileService" ref="mediaFileService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="transcodingSettingsController" class="org.libresonic.player.controller.TranscodingSettingsController">
|
||||
<property name="viewName" value="transcodingSettings"/>
|
||||
<property name="transcodingService" ref="transcodingService"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="internetRadioSettingsController"
|
||||
class="org.libresonic.player.controller.InternetRadioSettingsController">
|
||||
<property name="viewName" value="internetRadioSettings"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
<bean id="avatarUploadController" class="org.libresonic.player.controller.AvatarUploadController">
|
||||
<property name="viewName" value="avatarUploadResult"/>
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
<property name="securityService" ref="securityService"/>
|
||||
</bean>
|
||||
<bean id="editTagsController" class="org.libresonic.player.controller.EditTagsController">
|
||||
<property name="viewName" value="editTags"/>
|
||||
<property name="mediaFileService" ref="mediaFileService"/>
|
||||
<property name="metaDataParserFactory" ref="metaDataParserFactory"/>
|
||||
</bean>
|
||||
<bean id="avatarController" class="org.libresonic.player.controller.AvatarController">
|
||||
<property name="settingsService" ref="settingsService"/>
|
||||
</bean>
|
||||
@@ -166,13 +129,6 @@
|
||||
<prop key="/notFound.view">multiController</prop>
|
||||
<prop key="/index.view">multiController</prop>
|
||||
<prop key="/videoPlayer.view">videoPlayerController</prop>
|
||||
<prop key="/dlnaSettings.view">dlnaSettingsController</prop>
|
||||
<prop key="/sonosSettings.view">sonosSettingsController</prop>
|
||||
<prop key="/shareSettings.view">shareSettingsController</prop>
|
||||
<prop key="/transcodingSettings.view">transcodingSettingsController</prop>
|
||||
<prop key="/internetRadioSettings.view">internetRadioSettingsController</prop>
|
||||
<prop key="/avatarUpload.view">avatarUploadController</prop>
|
||||
<prop key="/editTags.view">editTagsController</prop>
|
||||
<prop key="/avatar.view">avatarController</prop>
|
||||
<prop key="/proxy.view">proxyController</prop>
|
||||
<prop key="/statusChart.view">statusChartController</prop>
|
||||
|
||||
Reference in New Issue
Block a user