Controllers migration.

master
Rémi Cocula 8 years ago
parent 2767d06731
commit 449f6a906a
  1. 22
      libresonic-main/src/main/java/org/libresonic/player/controller/AvatarUploadController.java
  2. 22
      libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java
  3. 43
      libresonic-main/src/main/java/org/libresonic/player/controller/EditTagsController.java
  4. 19
      libresonic-main/src/main/java/org/libresonic/player/controller/InternetRadioSettingsController.java
  5. 33
      libresonic-main/src/main/java/org/libresonic/player/controller/ShareSettingsController.java
  6. 23
      libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java
  7. 23
      libresonic-main/src/main/java/org/libresonic/player/controller/TranscodingSettingsController.java
  8. 44
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -30,6 +30,10 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
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.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.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
@ -50,15 +54,19 @@ import java.util.Map;
* *
* @author Sindre Mehus * @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 Logger LOG = Logger.getLogger(AvatarUploadController.class);
private static final int MAX_AVATAR_SIZE = 64; private static final int MAX_AVATAR_SIZE = 64;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String username = securityService.getCurrentUsername(request); String username = securityService.getCurrentUsername(request);
@ -93,9 +101,7 @@ public class AvatarUploadController extends ParameterizableViewController {
map.put("username", username); map.put("username", username);
map.put("avatar", settingsService.getCustomAvatar(username)); map.put("avatar", settingsService.getCustomAvatar(username));
ModelAndView result = super.handleRequestInternal(request, response); return new ModelAndView("avatarUploadResult","model",map);
result.addObject("model", map);
return result;
} }
private void createAvatar(String fileName, byte[] data, String username, Map<String, Object> map) throws IOException { 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;
}
} }

@ -25,7 +25,11 @@ 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.web.bind.ServletRequestUtils; 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.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
@ -37,12 +41,16 @@ import org.libresonic.player.service.UPnPService;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class DLNASettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/dlnaSettings")
public class DLNASettingsController {
@Autowired
private UPnPService upnpService; private UPnPService upnpService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -52,13 +60,11 @@ public class DLNASettingsController extends ParameterizableViewController {
map.put("toast", true); map.put("toast", true);
} }
ModelAndView result = super.handleRequestInternal(request, response);
map.put("dlnaEnabled", settingsService.isDlnaEnabled()); map.put("dlnaEnabled", settingsService.isDlnaEnabled());
map.put("dlnaServerName", settingsService.getDlnaServerName()); map.put("dlnaServerName", settingsService.getDlnaServerName());
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
result.addObject("model", map); return new ModelAndView("dlnaSettings","model",map);
return result;
} }
/** /**
@ -85,11 +91,5 @@ public class DLNASettingsController extends ParameterizableViewController {
upnpService.setMediaServerEnabled(dlnaEnabled); upnpService.setMediaServerEnabled(dlnaEnabled);
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setUpnpService(UPnPService upnpService) {
this.upnpService = upnpService;
}
} }

@ -19,35 +19,41 @@
*/ */
package org.libresonic.player.controller; 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.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.domain.MediaFile;
import org.libresonic.player.service.MediaFileService; import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.metadata.JaudiotaggerParser; import org.libresonic.player.service.metadata.JaudiotaggerParser;
import org.libresonic.player.service.metadata.MetaDataParser; import org.libresonic.player.service.metadata.MetaDataParser;
import org.libresonic.player.service.metadata.MetaDataParserFactory; 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. * Controller for the page used to edit MP3 tags.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class EditTagsController extends ParameterizableViewController { @Controller
@RequestMapping("/editTags")
public class EditTagsController {
@Autowired
private MetaDataParserFactory metaDataParserFactory; private MetaDataParserFactory metaDataParserFactory;
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id"); int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
@ -70,9 +76,7 @@ public class EditTagsController extends ParameterizableViewController {
map.put("id", id); map.put("id", id);
map.put("songs", songs); map.put("songs", songs);
ModelAndView result = super.handleRequestInternal(request, response); return new ModelAndView("editTags","model",map);
result.addObject("model", map);
return result;
} }
private Song createSong(MediaFile file, int index) { private Song createSong(MediaFile file, int index) {
@ -92,13 +96,6 @@ public class EditTagsController extends ParameterizableViewController {
return song; return song;
} }
public void setMetaDataParserFactory(MetaDataParserFactory metaDataParserFactory) {
this.metaDataParserFactory = metaDataParserFactory;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
/** /**
* Contains information about a single song. * Contains information about a single song.

@ -22,6 +22,10 @@ package org.libresonic.player.controller;
import org.libresonic.player.domain.InternetRadio; import org.libresonic.player.domain.InternetRadio;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
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.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.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
@ -37,11 +41,14 @@ import java.util.Map;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class InternetRadioSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/internetRadioSettings")
public class InternetRadioSettingsController {
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); 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)); map.put("internetRadios", settingsService.getAllInternetRadios(true));
return new ModelAndView("internetRadioSettings","model",map);
result.addObject("model", map);
return result;
} }
/** /**
@ -116,8 +120,5 @@ public class InternetRadioSettingsController extends ParameterizableViewControll
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]")); return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
} }

@ -30,7 +30,11 @@ 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.web.bind.ServletRequestUtils; 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.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
@ -48,14 +52,20 @@ import org.libresonic.player.service.ShareService;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class ShareSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/shareSettings")
public class ShareSettingsController {
@Autowired
private ShareService shareService; private ShareService shareService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -65,14 +75,12 @@ public class ShareSettingsController extends ParameterizableViewController {
map.put("toast", true); map.put("toast", true);
} }
ModelAndView result = super.handleRequestInternal(request, response);
map.put("shareBaseUrl", shareService.getShareBaseUrl()); map.put("shareBaseUrl", shareService.getShareBaseUrl());
map.put("shareInfos", getShareInfos(request)); map.put("shareInfos", getShareInfos(request));
map.put("user", securityService.getCurrentUser(request)); map.put("user", securityService.getCurrentUser(request));
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
result.addObject("model", map); return new ModelAndView("shareSettings","model",map);
return result;
} }
/** /**
@ -148,21 +156,6 @@ public class ShareSettingsController extends ParameterizableViewController {
return calendar.getTime(); 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 { public static class ShareInfo {
private final Share share; private final Share share;

@ -25,7 +25,11 @@ 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.web.bind.ServletRequestUtils; 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.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
@ -37,12 +41,16 @@ import org.libresonic.player.service.SonosService;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class SonosSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/sonosSettings")
public class SonosSettingsController {
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private SonosService sonosService; private SonosService sonosService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -52,13 +60,11 @@ public class SonosSettingsController extends ParameterizableViewController {
map.put("toast", true); map.put("toast", true);
} }
ModelAndView result = super.handleRequestInternal(request, response);
map.put("sonosEnabled", settingsService.isSonosEnabled()); map.put("sonosEnabled", settingsService.isSonosEnabled());
map.put("sonosServiceName", settingsService.getSonosServiceName()); map.put("sonosServiceName", settingsService.getSonosServiceName());
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
result.addObject("model", map); return new ModelAndView("sonosSettings","model",map);
return result;
} }
/** /**
@ -86,11 +92,4 @@ public class SonosSettingsController extends ParameterizableViewController {
sonosService.setMusicServiceEnabled(sonosEnabled); sonosService.setMusicServiceEnabled(sonosEnabled);
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSonosService(SonosService sonosService) {
this.sonosService = sonosService;
}
} }

@ -23,6 +23,10 @@ import org.libresonic.player.domain.Transcoding;
import org.libresonic.player.service.TranscodingService; import org.libresonic.player.service.TranscodingService;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
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.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.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
@ -36,12 +40,16 @@ import java.util.Map;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class TranscodingSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/transcodingSettings")
public class TranscodingSettingsController {
@Autowired
private TranscodingService transcodingService; private TranscodingService transcodingService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -51,15 +59,13 @@ public class TranscodingSettingsController extends ParameterizableViewController
map.put("toast", true); map.put("toast", true);
} }
ModelAndView result = super.handleRequestInternal(request, response);
map.put("transcodings", transcodingService.getAllTranscodings()); map.put("transcodings", transcodingService.getAllTranscodings());
map.put("transcodeDirectory", transcodingService.getTranscodeDirectory()); map.put("transcodeDirectory", transcodingService.getTranscodeDirectory());
map.put("downsampleCommand", settingsService.getDownsamplingCommand()); map.put("downsampleCommand", settingsService.getDownsamplingCommand());
map.put("hlsCommand", settingsService.getHlsCommand()); map.put("hlsCommand", settingsService.getHlsCommand());
map.put("brand", settingsService.getBrand()); map.put("brand", settingsService.getBrand());
result.addObject("model", map); return new ModelAndView("transcodingSettings","model",map);
return result;
} }
/** /**
@ -136,11 +142,4 @@ public class TranscodingSettingsController extends ParameterizableViewController
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]")); 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 /> <mvc:annotation-driven />
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/> <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"> <bean id="avatarController" class="org.libresonic.player.controller.AvatarController">
<property name="settingsService" ref="settingsService"/> <property name="settingsService" ref="settingsService"/>
</bean> </bean>
@ -166,13 +129,6 @@
<prop key="/notFound.view">multiController</prop> <prop key="/notFound.view">multiController</prop>
<prop key="/index.view">multiController</prop> <prop key="/index.view">multiController</prop>
<prop key="/videoPlayer.view">videoPlayerController</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="/avatar.view">avatarController</prop>
<prop key="/proxy.view">proxyController</prop> <prop key="/proxy.view">proxyController</prop>
<prop key="/statusChart.view">statusChartController</prop> <prop key="/statusChart.view">statusChartController</prop>

Loading…
Cancel
Save