Merge pull request #176 for Spring Boot. #yolo

master
Eugene E. Kashpureff Jr 8 years ago committed by GitHub
commit 0f58ad43e1
  1. 2
      libresonic-assembly/pom.xml
  2. 2
      libresonic-booter/pom.xml
  3. 2
      libresonic-installer-debian/pom.xml
  4. 2
      libresonic-installer-mac/pom.xml
  5. 2
      libresonic-installer-rpm/pom.xml
  6. 2
      libresonic-installer-windows/pom.xml
  7. 128
      libresonic-main/pom.xml
  8. 49
      libresonic-main/src/main/java/org/libresonic/player/boot/Application.java
  9. 2
      libresonic-main/src/main/java/org/libresonic/player/controller/AbstractChartController.java
  10. 28
      libresonic-main/src/main/java/org/libresonic/player/controller/AccessDeniedController.java
  11. 14
      libresonic-main/src/main/java/org/libresonic/player/controller/AllmusicController.java
  12. 14
      libresonic-main/src/main/java/org/libresonic/player/controller/AvatarController.java
  13. 22
      libresonic-main/src/main/java/org/libresonic/player/controller/AvatarUploadController.java
  14. 35
      libresonic-main/src/main/java/org/libresonic/player/controller/ChangeCoverArtController.java
  15. 35
      libresonic-main/src/main/java/org/libresonic/player/controller/ControllerUtils.java
  16. 117
      libresonic-main/src/main/java/org/libresonic/player/controller/CoverArtController.java
  17. 20
      libresonic-main/src/main/java/org/libresonic/player/controller/DBController.java
  18. 57
      libresonic-main/src/main/java/org/libresonic/player/controller/DownloadController.java
  19. 43
      libresonic-main/src/main/java/org/libresonic/player/controller/EditTagsController.java
  20. 51
      libresonic-main/src/main/java/org/libresonic/player/controller/ExportPlayListController.java
  21. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/ExternalPlayerController.java
  22. 61
      libresonic-main/src/main/java/org/libresonic/player/controller/GettingStartedController.java
  23. 26
      libresonic-main/src/main/java/org/libresonic/player/controller/HLSController.java
  24. 28
      libresonic-main/src/main/java/org/libresonic/player/controller/HelpController.java
  25. 98
      libresonic-main/src/main/java/org/libresonic/player/controller/HomeController.java
  26. 22
      libresonic-main/src/main/java/org/libresonic/player/controller/ImportPlaylistController.java
  27. 50
      libresonic-main/src/main/java/org/libresonic/player/controller/IndexController.java
  28. 78
      libresonic-main/src/main/java/org/libresonic/player/controller/LeftController.java
  29. 3
      libresonic-main/src/main/java/org/libresonic/player/controller/LoginController.java
  30. 14
      libresonic-main/src/main/java/org/libresonic/player/controller/LyricsController.java
  31. 40
      libresonic-main/src/main/java/org/libresonic/player/controller/M3UController.java
  32. 98
      libresonic-main/src/main/java/org/libresonic/player/controller/MainController.java
  33. 54
      libresonic-main/src/main/java/org/libresonic/player/controller/MoreController.java
  34. 7
      libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java
  35. 28
      libresonic-main/src/main/java/org/libresonic/player/controller/NotFoundController.java
  36. 40
      libresonic-main/src/main/java/org/libresonic/player/controller/NowPlayingController.java
  37. 34
      libresonic-main/src/main/java/org/libresonic/player/controller/PlayQueueController.java
  38. 34
      libresonic-main/src/main/java/org/libresonic/player/controller/PlaylistController.java
  39. 19
      libresonic-main/src/main/java/org/libresonic/player/controller/PlaylistsController.java
  40. 38
      libresonic-main/src/main/java/org/libresonic/player/controller/PodcastChannelController.java
  41. 49
      libresonic-main/src/main/java/org/libresonic/player/controller/PodcastChannelsController.java
  42. 36
      libresonic-main/src/main/java/org/libresonic/player/controller/PodcastController.java
  43. 20
      libresonic-main/src/main/java/org/libresonic/player/controller/PodcastReceiverAdminController.java
  44. 18
      libresonic-main/src/main/java/org/libresonic/player/controller/ProxyController.java
  45. 396
      libresonic-main/src/main/java/org/libresonic/player/controller/RESTController.java
  46. 177
      libresonic-main/src/main/java/org/libresonic/player/controller/RecoverController.java
  47. 46
      libresonic-main/src/main/java/org/libresonic/player/controller/RightController.java
  48. 26
      libresonic-main/src/main/java/org/libresonic/player/controller/SetMusicFileInfoController.java
  49. 41
      libresonic-main/src/main/java/org/libresonic/player/controller/SetRatingController.java
  50. 34
      libresonic-main/src/main/java/org/libresonic/player/controller/SettingsController.java
  51. 54
      libresonic-main/src/main/java/org/libresonic/player/controller/ShareManagementController.java
  52. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/StarredController.java
  53. 11
      libresonic-main/src/main/java/org/libresonic/player/controller/StatusChartController.java
  54. 35
      libresonic-main/src/main/java/org/libresonic/player/controller/StatusController.java
  55. 54
      libresonic-main/src/main/java/org/libresonic/player/controller/StreamController.java
  56. 28
      libresonic-main/src/main/java/org/libresonic/player/controller/TestController.java
  57. 43
      libresonic-main/src/main/java/org/libresonic/player/controller/TopController.java
  58. 73
      libresonic-main/src/main/java/org/libresonic/player/controller/UploadController.java
  59. 11
      libresonic-main/src/main/java/org/libresonic/player/controller/UserChartController.java
  60. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/VideoPlayerController.java
  61. 252
      libresonic-main/src/main/java/org/libresonic/player/controller/WapController.java
  62. 38
      libresonic-main/src/main/java/org/libresonic/player/security/CsrfSecurityRequestMatcher.java
  63. 2
      libresonic-main/src/main/java/org/libresonic/player/security/LoginFailureLogger.java
  64. 30
      libresonic-main/src/main/java/org/libresonic/player/security/RESTRequestParameterProcessingFilter.java
  65. 92
      libresonic-main/src/main/java/org/libresonic/player/security/WebSecurityConfig.java
  66. 0
      libresonic-main/src/main/resources/applicationContext-cache.xml
  67. 5
      libresonic-main/src/main/resources/applicationContext-db-embed.xml
  68. 0
      libresonic-main/src/main/resources/applicationContext-db-jndi.xml
  69. 5
      libresonic-main/src/main/resources/applicationContext-db-legacy.xml
  70. 0
      libresonic-main/src/main/resources/applicationContext-db.xml
  71. 0
      libresonic-main/src/main/resources/applicationContext-service.xml
  72. 0
      libresonic-main/src/main/resources/applicationContext-sonos.xml
  73. 50
      libresonic-main/src/main/resources/libresonic-servlet.xml
  74. 69
      libresonic-main/src/main/webapp/WEB-INF/applicationContext-security.xml
  75. 1
      libresonic-main/src/main/webapp/WEB-INF/jsp/include.jsp
  76. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/login.jsp
  77. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/podcastChannels.jsp
  78. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/videoPlayer.jsp
  79. 370
      libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml
  80. 30
      libresonic-main/src/test/resources/libresonic-rest-api-soapui-project.xml
  81. 2
      libresonic-rest-api/pom.xml
  82. 2
      libresonic-sonos-api/pom.xml
  83. 85
      pom.xml

@ -9,7 +9,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<dependencies>

@ -8,7 +8,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<dependencies>

@ -9,7 +9,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<profiles>

@ -9,7 +9,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<dependencies>

@ -9,7 +9,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<profiles>

@ -9,7 +9,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<properties>

@ -9,7 +9,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<properties>
@ -30,63 +30,63 @@
<version>${project.version}</version>
</dependency>
<!-- Metrics -->
<!-- Metrics
Metrics is a cool framework used here
to compute musures and statistics during automated testing
-->
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
<scope>test</scope>
</dependency>
<!-- END Metrics -->
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
<!-- END Spring -->
<!-- taglibs -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<groupId>taglibs</groupId>
<artifactId>string</artifactId>
<version>1.1.0</version>
</dependency>
<!-- END taglibs -->
<dependency>
<groupId>org.apache.lucene</groupId>
@ -162,19 +162,6 @@
<version>1.0-b2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.directwebremoting</groupId>
@ -236,46 +223,12 @@
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>string</artifactId>
<version>1.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.hoodcomputing</groupId>
<artifactId>natpmp</artifactId>
@ -386,6 +339,10 @@
<id>full</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
@ -410,7 +367,20 @@
<build>
<finalName>libresonic</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>org.libresonic.player.boot.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>

@ -0,0 +1,49 @@
package org.libresonic.player.boot;
import org.directwebremoting.servlet.DwrServlet;
import org.libresonic.player.spring.AdditionalPropertySourceConfigurer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@Configuration
@ImportResource(value = {"classpath:/applicationContext-service.xml",
"classpath:/applicationContext-cache.xml",
"classpath:/applicationContext-sonos.xml",
"classpath:/libresonic-servlet.xml"})
public class Application extends SpringBootServletInitializer {
/**
* Registers the DWR servlet.
*
* @return a registration bean.
*/
@Bean
public ServletRegistrationBean dwrServletRegistrationBean() {
ServletRegistrationBean servlet = new ServletRegistrationBean(new DwrServlet(), "/dwr/*");
servlet.addInitParameter("crossDomainSessionSecurity","false");
return servlet;
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// Customize the application or call application.sources(...) to add sources
// Since our example is itself a @Configuration class (via @SpringBootApplication)
// we actually don't need to override this method.
return application;
}
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Application.class);
springApplication.addInitializers(new AdditionalPropertySourceConfigurer());
springApplication.run(args);
}
}

@ -32,7 +32,7 @@ import java.util.*;
*
* @author Sindre Mehus
*/
public abstract class AbstractChartController implements Controller {
public abstract class AbstractChartController {
/**
* Returns the chart background color for the current theme.

@ -0,0 +1,28 @@
package org.libresonic.player.controller;
import org.libresonic.player.Logger;
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;
/**
* Spring MVC Controller that serves the login page.
*/
@Controller
@RequestMapping("/accessDenied")
public class AccessDeniedController {
private static final Logger LOG = Logger.getLogger(AccessDeniedController.class);
@RequestMapping(method = {RequestMethod.GET})
public ModelAndView accessDenied(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("accessDenied");
}
}

@ -19,8 +19,11 @@
*/
package org.libresonic.player.controller;
import org.springframework.web.servlet.*;
import org.springframework.web.servlet.mvc.*;
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.*;
@ -29,10 +32,13 @@ import javax.servlet.http.*;
*
* @author Sindre Mehus
*/
public class AllmusicController extends ParameterizableViewController {
@Controller
@RequestMapping("/allmusic")
public class AllmusicController {
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView result = super.handleRequestInternal(request, response);
ModelAndView result = new ModelAndView();
result.addObject("album", request.getParameter("album"));
return result;
}

@ -22,9 +22,12 @@ package org.libresonic.player.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.Controller;
import org.springframework.web.servlet.mvc.LastModified;
import org.libresonic.player.domain.Avatar;
@ -37,8 +40,11 @@ import org.libresonic.player.service.SettingsService;
*
* @author Sindre Mehus
*/
public class AvatarController implements Controller, LastModified {
@Controller
@RequestMapping("/avatar")
public class AvatarController implements LastModified {
@Autowired
private SettingsService settingsService;
public long getLastModified(HttpServletRequest request) {
@ -54,6 +60,7 @@ public class AvatarController implements Controller, LastModified {
return result;
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
Avatar avatar = getAvatar(request);
@ -87,7 +94,4 @@ public class AvatarController implements Controller, LastModified {
return settingsService.getSystemAvatar(userSettings.getSystemAvatarId());
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
}

@ -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;
}
}

@ -19,30 +19,34 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
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;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* Controller for changing cover art.
*
* @author Sindre Mehus
*/
public class ChangeCoverArtController extends ParameterizableViewController {
@Controller
@RequestMapping("/changeCoverArt")
public class ChangeCoverArtController {
@Autowired
private MediaFileService mediaFileService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
@ -57,18 +61,13 @@ public class ChangeCoverArtController extends ParameterizableViewController {
album = dir.getAlbumName();
}
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("artist", artist);
map.put("album", album);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("changeCoverArt","model",map);
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -0,0 +1,35 @@
package org.libresonic.player.controller;
import org.apache.commons.lang.ObjectUtils;
import org.libresonic.player.service.SettingsService;
import javax.servlet.http.HttpServletRequest;
/**
* This class has been created to refactor code previously present
* in the MultiController.
*/
public class ControllerUtils {
public static void updatePortAndContextPath(HttpServletRequest request, SettingsService settingsService) {
int port = Integer.parseInt(System.getProperty("libresonic.port", String.valueOf(request.getLocalPort())));
int httpsPort = Integer.parseInt(System.getProperty("libresonic.httpsPort", "0"));
String contextPath = request.getContextPath().replace("/", "");
if (settingsService.getPort() != port) {
settingsService.setPort(port);
settingsService.save();
}
if (settingsService.getHttpsPort() != httpsPort) {
settingsService.setHttpsPort(httpsPort);
settingsService.save();
}
if (!ObjectUtils.equals(settingsService.getUrlRedirectContextPath(), contextPath)) {
settingsService.setUrlRedirectContextPath(contextPath);
settingsService.save();
}
}
}

@ -19,62 +19,45 @@
*/
package org.libresonic.player.controller;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Semaphore;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.LastModified;
import org.libresonic.player.Logger;
import org.libresonic.player.dao.AlbumDao;
import org.libresonic.player.dao.ArtistDao;
import org.libresonic.player.domain.Album;
import org.libresonic.player.domain.Artist;
import org.libresonic.player.domain.CoverArtScheme;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.Playlist;
import org.libresonic.player.domain.PodcastChannel;
import org.libresonic.player.domain.Transcoding;
import org.libresonic.player.domain.VideoTranscodingSettings;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.PodcastService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.TranscodingService;
import org.libresonic.player.domain.*;
import org.libresonic.player.service.*;
import org.libresonic.player.service.metadata.JaudiotaggerParser;
import org.libresonic.player.util.StringUtil;
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.LastModified;
import javax.annotation.PostConstruct;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Semaphore;
/**
* Controller which produces cover art images.
*
* @author Sindre Mehus
*/
public class CoverArtController implements Controller, LastModified {
@Controller
@RequestMapping("/coverArt")
public class CoverArtController implements LastModified {
public static final String ALBUM_COVERART_PREFIX = "al-";
public static final String ARTIST_COVERART_PREFIX = "ar-";
@ -83,26 +66,34 @@ public class CoverArtController implements Controller, LastModified {
private static final Logger LOG = Logger.getLogger(CoverArtController.class);
@Autowired
private MediaFileService mediaFileService;
@Autowired
private TranscodingService transcodingService;
@Autowired
private SettingsService settingsService;
@Autowired
private PlaylistService playlistService;
@Autowired
private PodcastService podcastService;
@Autowired
private ArtistDao artistDao;
@Autowired
private AlbumDao albumDao;
private Semaphore semaphore;
@PostConstruct
public void init() {
semaphore = new Semaphore(settingsService.getCoverArtConcurrency());
}
public long getLastModified(HttpServletRequest request) {
CoverArtRequest coverArtRequest = createCoverArtRequest(request);
long result = coverArtRequest.lastModified();
// LOG.info("getLastModified - " + coverArtRequest + ": " + new Date(result));
return result;
// LOG.info("getLastModified - " + coverArtRequest + ": " + new Date(result));
return coverArtRequest.lastModified();
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
CoverArtRequest coverArtRequest = createCoverArtRequest(request);
@ -341,33 +332,6 @@ public class CoverArtController implements Controller, LastModified {
return thumb;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setArtistDao(ArtistDao artistDao) {
this.artistDao = artistDao;
}
public void setAlbumDao(AlbumDao albumDao) {
this.albumDao = albumDao;
}
public void setTranscodingService(TranscodingService transcodingService) {
this.transcodingService = transcodingService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setPodcastService(PodcastService podcastService) {
this.podcastService = podcastService;
}
private abstract class CoverArtRequest {
@ -551,7 +515,7 @@ public class CoverArtController implements Controller, LastModified {
albums.add(album);
}
}
return new ArrayList<MediaFile>(albums);
return new ArrayList<>(albums);
}
}
@ -559,7 +523,7 @@ public class CoverArtController implements Controller, LastModified {
private final PodcastChannel channel;
public PodcastCoverArtRequest(PodcastChannel channel) {
PodcastCoverArtRequest(PodcastChannel channel) {
this.channel = channel;
}
@ -633,7 +597,8 @@ public class CoverArtController implements Controller, LastModified {
@Override
public BufferedImage createImage(int size) {
int height = size;
int height;
height = size;
int width = height * 16 / 9;
InputStream in = null;
try {
@ -687,7 +652,7 @@ public class CoverArtController implements Controller, LastModified {
private final int height;
private final Color color;
public AutoCover(Graphics2D graphics, String key, String artist, String album, int width, int height) {
AutoCover(Graphics2D graphics, String key, String artist, String album, int width, int height) {
this.graphics = graphics;
this.artist = artist;
this.album = album;

@ -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;
}
}

@ -38,10 +38,13 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
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.Controller;
import org.springframework.web.servlet.mvc.LastModified;
import org.libresonic.player.Logger;
@ -69,15 +72,23 @@ import org.libresonic.player.util.Util;
*
* @author Sindre Mehus
*/
public class DownloadController implements Controller, LastModified {
@Controller
@RequestMapping("/download")
public class DownloadController implements LastModified {
private static final Logger LOG = Logger.getLogger(DownloadController.class);
@Autowired
private PlayerService playerService;
@Autowired
private StatusService statusService;
@Autowired
private SecurityService securityService;
@Autowired
private PlaylistService playlistService;
@Autowired
private SettingsService settingsService;
@Autowired
private MediaFileService mediaFileService;
public long getLastModified(HttpServletRequest request) {
@ -92,6 +103,7 @@ public class DownloadController implements Controller, LastModified {
}
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
@ -120,7 +132,7 @@ public class DownloadController implements Controller, LastModified {
if (mediaFile != null) {
if (!securityService.isFolderAccessAllowed(mediaFile, user.getUsername())) {
response.sendError(HttpServletResponse.SC_FORBIDDEN,
"Access to file " + mediaFile.getId() + " is forbidden for user " + user.getUsername());
"Access to file " + mediaFile.getId() + " is forbidden for user " + user.getUsername());
return null;
}
@ -163,7 +175,6 @@ public class DownloadController implements Controller, LastModified {
/**
* Downloads a single file.
*
*
* @param response The HTTP response.
* @param status The download status.
* @param file The file to download.
@ -205,14 +216,13 @@ public class DownloadController implements Controller, LastModified {
* Downloads the given files. The files are packed together in an
* uncompressed zip-file.
*
*
* @param response The HTTP response.
* @param status The download status.
* @param files The files to download.
* @param indexes Only download songs at these indexes. May be <code>null</code>.
* @param response The HTTP response.
* @param status The download status.
* @param files The files to download.
* @param indexes Only download songs at these indexes. May be <code>null</code>.
* @param coverArtFile The cover art file to include, may be {@code null}.
*@param range The byte range, may be <code>null</code>.
* @param zipFileName The name of the resulting zip file. @throws IOException If an I/O error occurs.
* @param range The byte range, may be <code>null</code>.
* @param zipFileName The name of the resulting zip file. @throws IOException If an I/O error occurs.
*/
private void downloadFiles(HttpServletResponse response, TransferStatus status, List<MediaFile> files, int[] indexes, File coverArtFile, HttpRange range, String zipFileName) throws IOException {
if (indexes != null && indexes.length == 1) {
@ -253,7 +263,6 @@ public class DownloadController implements Controller, LastModified {
/**
* Utility method for writing the content of a given file to a given output stream.
*
*
* @param file The file to copy.
* @param out The output stream to write to.
* @param status The download status.
@ -317,7 +326,6 @@ public class DownloadController implements Controller, LastModified {
* Writes a file or a directory structure to a zip output stream. File entries in the zip file are relative
* to the given root.
*
*
* @param out The zip output stream.
* @param root The root of the directory structure. Used to create path information in the zip file.
* @param file The file or directory to zip.
@ -389,27 +397,4 @@ public class DownloadController implements Controller, LastModified {
return crc.getValue();
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -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.

@ -0,0 +1,51 @@
package org.libresonic.player.controller;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.Playlist;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.util.StringUtil;
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;
/**
* Spring MVC Controller that serves the login page.
*/
@Controller
@RequestMapping("/exportPlaylist")
public class ExportPlayListController {
private static final Logger LOG = Logger.getLogger(ExportPlayListController.class);
@Autowired
private PlaylistService playlistService;
@Autowired
private SecurityService securityService;
@RequestMapping(method = { RequestMethod.GET })
public ModelAndView exportPlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Playlist playlist = playlistService.getPlaylist(id);
if (!playlistService.isReadAllowed(playlist, securityService.getCurrentUsername(request))) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return null;
}
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=\"" + StringUtil.fileSystemSafe(playlist.getName()) + ".m3u8\"");
playlistService.exportPlaylist(id, response.getOutputStream());
return null;
}
}

@ -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;
}
}

@ -0,0 +1,61 @@
/*
This file is part of Libresonic.
Libresonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Libresonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2016 (C) Libresonic Authors
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
*/
package org.libresonic.player.controller;
import org.libresonic.player.domain.AvatarScheme;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/gettingStarted")
public class GettingStartedController {
@Autowired
private SettingsService settingsService;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView gettingStarted(HttpServletRequest request) {
ControllerUtils.updatePortAndContextPath(request,settingsService);
if (request.getParameter("hide") != null) {
settingsService.setGettingStartedEnabled(false);
settingsService.save();
return new ModelAndView(new RedirectView("home.view"));
}
Map<String, Object> map = new HashMap<>();;
map.put("runningAsRoot", "root".equals(System.getProperty("user.name")));
return new ModelAndView("gettingStarted", "model", map);
}
}

@ -30,9 +30,12 @@ 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.Controller;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.Player;
@ -47,15 +50,21 @@ import org.libresonic.player.util.StringUtil;
*
* @author Sindre Mehus
*/
public class HLSController implements Controller {
@Controller(value = "hlsController")
@RequestMapping("/hls/**")
public class HLSController {
private static final int SEGMENT_DURATION = 10;
private static final Pattern BITRATE_PATTERN = Pattern.compile("(\\d+)(@(\\d+)x(\\d+))?");
@Autowired
private PlayerService playerService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SecurityService securityService;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setHeader("Access-Control-Allow-Origin", "*");
@ -72,7 +81,7 @@ public class HLSController implements Controller {
if (username != null && !securityService.isFolderAccessAllowed(mediaFile, username)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN,
"Access to file " + mediaFile.getId() + " is forbidden for user " + username);
"Access to file " + mediaFile.getId() + " is forbidden for user " + username);
return null;
}
@ -188,15 +197,4 @@ public class HLSController implements Controller {
return contextPath;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}

@ -25,6 +25,10 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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;
@ -38,15 +42,20 @@ import org.libresonic.player.service.VersionService;
*
* @author Sindre Mehus
*/
public class HelpController extends ParameterizableViewController {
@Controller
@RequestMapping("/help")
public class HelpController {
@Autowired
private VersionService versionService;
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
if (versionService.isNewFinalVersionAvailable()) {
map.put("newVersionAvailable", true);
@ -74,20 +83,9 @@ public class HelpController extends ParameterizableViewController {
map.put("logEntries", Logger.getLatestLogEntries());
map.put("logFile", Logger.getLogFile());
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("help","model",map);
}
public void setVersionService(VersionService versionService) {
this.versionService = versionService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}

@ -19,35 +19,18 @@
*/
package org.libresonic.player.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
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.libresonic.player.domain.*;
import org.libresonic.player.service.*;
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;
import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.AlbumListType;
import org.libresonic.player.domain.CoverArtScheme;
import org.libresonic.player.domain.Genre;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.MediaScannerService;
import org.libresonic.player.service.RatingService;
import org.libresonic.player.service.SearchService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*;
import static org.springframework.web.bind.ServletRequestUtils.getIntParameter;
import static org.springframework.web.bind.ServletRequestUtils.getStringParameter;
@ -57,18 +40,27 @@ import static org.springframework.web.bind.ServletRequestUtils.getStringParamete
*
* @author Sindre Mehus
*/
public class HomeController extends ParameterizableViewController {
@Controller
@RequestMapping("/home")
public class HomeController {
private static final int LIST_SIZE = 40;
@Autowired
private SettingsService settingsService;
@Autowired
private MediaScannerService mediaScannerService;
@Autowired
private RatingService ratingService;
@Autowired
private SecurityService securityService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SearchService searchService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
User user = securityService.getCurrentUser(request);
if (user.isAdminRole() && settingsService.isGettingStartedEnabled()) {
@ -85,7 +77,7 @@ public class HomeController extends ParameterizableViewController {
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(user.getUsername(),
selectedMusicFolder == null ? null : selectedMusicFolder.getId());
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
List<Album> albums = Collections.emptyList();
switch (listType) {
case HIGHEST:
@ -142,13 +134,11 @@ public class HomeController extends ParameterizableViewController {
map.put("musicFolder", selectedMusicFolder);
map.put("listReloadDelay", userSettings.getListReloadDelay());
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("home","model",map);
}
private List<Album> getHighestRated(int offset, int count, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile mediaFile : ratingService.getHighestRatedAlbums(offset, count, musicFolders)) {
Album album = createAlbum(mediaFile);
album.setRating((int) Math.round(ratingService.getAverageRating(mediaFile) * 10.0D));
@ -158,7 +148,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getMostFrequent(int offset, int count, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile mediaFile : mediaFileService.getMostFrequentlyPlayedAlbums(offset, count, musicFolders)) {
Album album = createAlbum(mediaFile);
album.setPlayCount(mediaFile.getPlayCount());
@ -168,7 +158,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getMostRecent(int offset, int count, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile mediaFile : mediaFileService.getMostRecentlyPlayedAlbums(offset, count, musicFolders)) {
Album album = createAlbum(mediaFile);
album.setLastPlayed(mediaFile.getLastPlayed());
@ -178,7 +168,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getNewest(int offset, int count, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getNewestAlbums(offset, count, musicFolders)) {
Album album = createAlbum(file);
Date created = file.getCreated();
@ -192,7 +182,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getStarred(int offset, int count, String username, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getStarredAlbums(offset, count, username, musicFolders)) {
result.add(createAlbum(file));
}
@ -200,7 +190,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getRandom(int count, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile file : searchService.getRandomAlbums(count, musicFolders)) {
result.add(createAlbum(file));
}
@ -208,7 +198,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getAlphabetical(int offset, int count, boolean byArtist, List<MusicFolder> musicFolders) throws IOException {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getAlphabeticalAlbums(offset, count, byArtist, musicFolders)) {
result.add(createAlbum(file));
}
@ -216,7 +206,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getByYear(int offset, int count, int fromYear, int toYear, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getAlbumsByYear(offset, count, fromYear, toYear, musicFolders)) {
Album album = createAlbum(file);
album.setYear(file.getYear());
@ -226,7 +216,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Integer> createDecades() {
List<Integer> result = new ArrayList<Integer>();
List<Integer> result = new ArrayList<>();
int decade = Calendar.getInstance().get(Calendar.YEAR) / 10;
for (int i = 0; i < 10; i++) {
result.add((decade - i) * 10);
@ -235,7 +225,7 @@ public class HomeController extends ParameterizableViewController {
}
private List<Album> getByGenre(int offset, int count, String genre, List<MusicFolder> musicFolders) {
List<Album> result = new ArrayList<Album>();
List<Album> result = new ArrayList<>();
for (MediaFile file : mediaFileService.getAlbumsByGenre(offset, count, genre, musicFolders)) {
result.add(createAlbum(file));
}
@ -252,30 +242,6 @@ public class HomeController extends ParameterizableViewController {
return album;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setMediaScannerService(MediaScannerService mediaScannerService) {
this.mediaScannerService = mediaScannerService;
}
public void setRatingService(RatingService ratingService) {
this.ratingService = ratingService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
/**
* Contains info for a single album.
*/

@ -32,6 +32,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;
@ -42,14 +46,18 @@ import org.libresonic.player.service.SecurityService;
/**
* @author Sindre Mehus
*/
public class ImportPlaylistController extends ParameterizableViewController {
@Controller
@RequestMapping("/importPlaylist")
public class ImportPlaylistController {
private static final long MAX_PLAYLIST_SIZE_MB = 5L;
@Autowired
private SecurityService securityService;
@Autowired
private PlaylistService playlistService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
@ -79,16 +87,8 @@ public class ImportPlaylistController extends ParameterizableViewController {
map.put("error", e.getMessage());
}
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("importPlaylist","model",map);
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
}

@ -0,0 +1,50 @@
package org.libresonic.player.controller;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
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.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/index")
public class IndexController {
private static final Logger LOG = Logger.getLogger(IndexController.class);
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
@RequestMapping(method = { RequestMethod.GET})
public ModelAndView index(HttpServletRequest request) {
ControllerUtils.updatePortAndContextPath(request,settingsService);
UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));
Map<String, Object> map = new HashMap<String, Object>();
map.put("showRight", userSettings.isShowNowPlayingEnabled() || userSettings.isShowChatEnabled());
map.put("autoHidePlayQueue", userSettings.isAutoHidePlayQueue());
map.put("listReloadDelay", userSettings.getListReloadDelay());
map.put("keyboardShortcutsEnabled", userSettings.isKeyboardShortcutsEnabled());
map.put("showSideBar", userSettings.isShowSideBar());
map.put("brand", settingsService.getBrand());
return new ModelAndView("index", "model", map);
}
}

@ -19,41 +19,31 @@
*/
package org.libresonic.player.controller;
import java.io.File;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.libresonic.player.domain.*;
import org.libresonic.player.service.*;
import org.libresonic.player.util.FileUtil;
import org.libresonic.player.util.StringUtil;
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;
import org.springframework.web.servlet.support.RequestContextUtils;
import org.libresonic.player.domain.InternetRadio;
import org.libresonic.player.domain.MediaLibraryStatistics;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.MusicFolderContent;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.MediaScannerService;
import org.libresonic.player.service.MusicIndexService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.FileUtil;
import org.libresonic.player.util.StringUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.*;
/**
* Controller for the left index frame.
*
* @author Sindre Mehus
*/
public class LeftController extends ParameterizableViewController {
@Controller
@RequestMapping("/left")
public class LeftController {
// Update this time if you want to force a refresh in clients.
private static final Calendar LAST_COMPATIBILITY_TIME = Calendar.getInstance();
@ -62,17 +52,22 @@ public class LeftController extends ParameterizableViewController {
LAST_COMPATIBILITY_TIME.set(Calendar.MILLISECOND, 0);
}
@Autowired
private MediaScannerService mediaScannerService;
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@Autowired
private MusicIndexService musicIndexService;
@Autowired
private PlayerService playerService;
/**
* Note: This class intentionally does not implement org.springframework.web.servlet.mvc.LastModified
* as we don't need browser-side caching of left.jsp. This method is only used by RESTController.
*/
public long getLastModified(HttpServletRequest request) {
long getLastModified(HttpServletRequest request) {
saveSelectedMusicFolder(request);
if (mediaScannerService.isScanning()) {
@ -115,10 +110,10 @@ public class LeftController extends ParameterizableViewController {
return lastModified;
}
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
boolean musicFolderChanged = saveSelectedMusicFolder(request);
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
MediaLibraryStatistics statistics = mediaScannerService.getStatistics();
Locale locale = RequestContextUtils.getLocale(request);
@ -131,7 +126,7 @@ public class LeftController extends ParameterizableViewController {
String username = securityService.getCurrentUsername(request);
List<MusicFolder> allMusicFolders = settingsService.getMusicFoldersForUser(username);
MusicFolder selectedMusicFolder = settingsService.getSelectedMusicFolder(username);
List<MusicFolder> musicFoldersToUse = selectedMusicFolder == null ? allMusicFolders : Arrays.asList(selectedMusicFolder);
List<MusicFolder> musicFoldersToUse = selectedMusicFolder == null ? allMusicFolders : Collections.singletonList(selectedMusicFolder);
UserSettings userSettings = settingsService.getUserSettings(username);
MusicFolderContent musicFolderContent = musicIndexService.getMusicFolderContent(musicFoldersToUse, refresh);
@ -158,9 +153,7 @@ public class LeftController extends ParameterizableViewController {
map.put("indexes", musicFolderContent.getIndexedArtists().keySet());
map.put("user", securityService.getCurrentUser(request));
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("left","model",map);
}
private boolean saveSelectedMusicFolder(HttpServletRequest request) {
@ -177,25 +170,4 @@ public class LeftController extends ParameterizableViewController {
return true;
}
public void setMediaScannerService(MediaScannerService mediaScannerService) {
this.mediaScannerService = mediaScannerService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setMusicIndexService(MusicIndexService musicIndexService) {
this.musicIndexService = musicIndexService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
}

@ -2,7 +2,6 @@ package org.libresonic.player.controller;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.User;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
@ -43,7 +42,7 @@ public class LoginController {
if (username != null && password != null) {
username = StringUtil.urlEncode(username);
password = StringUtil.urlEncode(password);
return new ModelAndView(new RedirectView("/j_spring_security_check?"+
return new ModelAndView(new RedirectView("/login?"+
UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY+"=" + username +
"&"+UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY+"=" + password
));

@ -19,6 +19,9 @@
*/
package org.libresonic.player.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.ModelAndView;
@ -32,16 +35,17 @@ import java.util.HashMap;
*
* @author Sindre Mehus
*/
public class LyricsController extends ParameterizableViewController {
@Controller
@RequestMapping("/lyrics")
public class LyricsController {
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("artist", request.getParameter("artist"));
map.put("song", request.getParameter("song"));
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("lyrics","model",map);
}
}

@ -19,16 +19,6 @@
*/
package org.libresonic.player.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.PlayQueue;
import org.libresonic.player.domain.Player;
@ -36,18 +26,35 @@ import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.TranscodingService;
import org.libresonic.player.util.StringUtil;
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.io.PrintWriter;
import java.util.List;
/**
* Controller which produces the M3U playlist.
*
* @author Sindre Mehus
*/
public class M3UController implements Controller {
@Controller
@RequestMapping("/play.m3u")
public class M3UController {
@Autowired
private PlayerService playerService;
@Autowired
private SettingsService settingsService;
@Autowired
private TranscodingService transcodingService;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setContentType("audio/x-mpegurl");
response.setCharacterEncoding(StringUtil.ENCODING_UTF8);
@ -115,15 +122,4 @@ public class M3UController implements Controller {
return playQueue.isEmpty() ? null : transcodingService.getSuffix(player, playQueue.getFile(0), null);
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setTranscodingService(TranscodingService transcodingService) {
this.transcodingService = transcodingService;
}
}

@ -19,54 +19,47 @@
*/
package org.libresonic.player.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.libresonic.player.domain.*;
import org.libresonic.player.service.*;
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.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.CoverArtScheme;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MediaFileComparator;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.AdService;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.RatingService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
* Controller for the main page.
*
* @author Sindre Mehus
*/
public class MainController extends AbstractController {
@Controller
@RequestMapping("/main")
public class MainController {
@Autowired
private SecurityService securityService;
@Autowired
private PlayerService playerService;
@Autowired
private SettingsService settingsService;
@Autowired
private RatingService ratingService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private AdService adService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
Player player = playerService.getPlayer(request, response);
List<MediaFile> mediaFiles = getMediaFiles(request);
@ -91,8 +84,8 @@ public class MainController extends AbstractController {
}
List<MediaFile> children = mediaFiles.size() == 1 ? mediaFileService.getChildrenOf(dir, true, true, true) : getMultiFolderChildren(mediaFiles);
List<MediaFile> files = new ArrayList<MediaFile>();
List<MediaFile> subDirs = new ArrayList<MediaFile>();
List<MediaFile> files = new ArrayList<>();
List<MediaFile> subDirs = new ArrayList<>();
for (MediaFile child : children) {
if (child.isFile()) {
files.add(child);
@ -158,9 +151,7 @@ public class MainController extends AbstractController {
view = "artistMain";
}
ModelAndView result = new ModelAndView(view);
result.addObject("model", map);
return result;
return new ModelAndView(view,"model",map);
}
private boolean isViewAsList(HttpServletRequest request, UserSettings userSettings) {
@ -187,7 +178,7 @@ public class MainController extends AbstractController {
}
private List<MediaFile> getMediaFiles(HttpServletRequest request) {
List<MediaFile> mediaFiles = new ArrayList<MediaFile>();
List<MediaFile> mediaFiles = new ArrayList<>();
for (String path : ServletRequestUtils.getStringParameters(request, "path")) {
MediaFile mediaFile = mediaFileService.getMediaFile(path);
if (mediaFile != null) {
@ -222,18 +213,18 @@ public class MainController extends AbstractController {
}
private List<MediaFile> getMultiFolderChildren(List<MediaFile> mediaFiles) throws IOException {
SortedSet<MediaFile> result = new TreeSet<MediaFile>(new MediaFileComparator(settingsService.isSortAlbumsByYear()));
SortedSet<MediaFile> result = new TreeSet<>(new MediaFileComparator(settingsService.isSortAlbumsByYear()));
for (MediaFile mediaFile : mediaFiles) {
if (mediaFile.isFile()) {
mediaFile = mediaFileService.getParentOf(mediaFile);
}
result.addAll(mediaFileService.getChildrenOf(mediaFile, true, true, true));
}
return new ArrayList<MediaFile>(result);
return new ArrayList<>(result);
}
private List<MediaFile> getAncestors(MediaFile dir) throws IOException {
LinkedList<MediaFile> result = new LinkedList<MediaFile>();
LinkedList<MediaFile> result = new LinkedList<>();
try {
MediaFile parent = mediaFileService.getParentOf(dir);
@ -248,41 +239,14 @@ public class MainController extends AbstractController {
}
private List<MediaFile> getSieblingAlbums(MediaFile dir) {
List<MediaFile> result = new ArrayList<MediaFile>();
List<MediaFile> result = new ArrayList<>();
MediaFile parent = mediaFileService.getParentOf(dir);
if (!mediaFileService.isRoot(parent)) {
List<MediaFile> sieblings = mediaFileService.getChildrenOf(parent, false, true, true);
for (MediaFile siebling : sieblings) {
if (siebling.isAlbum() && !siebling.equals(dir)) {
result.add(siebling);
}
}
result.addAll(sieblings.stream().filter(siebling -> siebling.isAlbum() && !siebling.equals(dir)).collect(Collectors.toList()));
}
return result;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setRatingService(RatingService ratingService) {
this.ratingService = ratingService;
}
public void setAdService(AdService adService) {
this.adService = adService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -19,18 +19,6 @@
*/
package org.libresonic.player.controller;
import java.io.File;
import java.util.Calendar;
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.MusicFolder;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.User;
@ -39,21 +27,41 @@ import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
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.File;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Controller for the "more" page.
*
* @author Sindre Mehus
*/
public class MoreController extends ParameterizableViewController {
@Controller
@RequestMapping("/more")
public class MoreController {
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@Autowired
private PlayerService playerService;
@Autowired
private MediaFileService mediaFileService;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
@ -72,7 +80,7 @@ public class MoreController extends ParameterizableViewController {
}
Player player = playerService.getPlayer(request, response);
ModelAndView result = super.handleRequestInternal(request, response);
ModelAndView result = new ModelAndView();
result.addObject("model", map);
map.put("user", user);
map.put("uploadDirectory", uploadDirectory);
@ -84,20 +92,4 @@ public class MoreController extends ParameterizableViewController {
map.put("jamstashUrl", jamstashUrl);
return result;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -37,6 +37,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Controller for the page used to administrate the set of music folders.
@ -96,11 +97,7 @@ public class MusicFolderSettingsController {
}
private List<MusicFolderSettingsCommand.MusicFolderInfo> wrap(List<MusicFolder> musicFolders) {
ArrayList<MusicFolderSettingsCommand.MusicFolderInfo> result = new ArrayList<MusicFolderSettingsCommand.MusicFolderInfo>();
for (MusicFolder musicFolder : musicFolders) {
result.add(new MusicFolderSettingsCommand.MusicFolderInfo(musicFolder));
}
return result;
return musicFolders.stream().map(MusicFolderSettingsCommand.MusicFolderInfo::new).collect(Collectors.toCollection(ArrayList::new));
}
@RequestMapping(method = RequestMethod.POST)

@ -0,0 +1,28 @@
package org.libresonic.player.controller;
import org.libresonic.player.Logger;
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;
/**
* Spring MVC Controller that serves the login page.
*/
@Controller
@RequestMapping("/notFound")
public class NotFoundController {
private static final Logger LOG = Logger.getLogger(NotFoundController.class);
@RequestMapping(method = {RequestMethod.GET})
public ModelAndView notFound(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("notFound");
}
}

@ -19,34 +19,40 @@
*/
package org.libresonic.player.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.TransferStatus;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.StatusService;
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.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller for showing what's currently playing.
*
* @author Sindre Mehus
*/
public class NowPlayingController extends AbstractController {
@Controller
@RequestMapping("/nowPlaying")
public class NowPlayingController {
@Autowired
private PlayerService playerService;
@Autowired
private StatusService statusService;
@Autowired
private MediaFileService mediaFileService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Player player = playerService.getPlayer(request, response);
@ -64,16 +70,4 @@ public class NowPlayingController extends AbstractController {
return new ModelAndView(new RedirectView(url));
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -19,41 +19,47 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
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.Player;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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.util.HashMap;
import java.util.Map;
/**
* Controller for the playlist frame.
*
* @author Sindre Mehus
*/
public class PlayQueueController extends ParameterizableViewController {
@Controller
@RequestMapping("/playQueue")
public class PlayQueueController {
@Autowired
private PlayerService playerService;
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
Player player = playerService.getPlayer(request, response);
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("user", user);
map.put("player", player);
map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null));
@ -61,9 +67,7 @@ public class PlayQueueController extends ParameterizableViewController {
map.put("partyMode", userSettings.isPartyModeEnabled());
map.put("notify", userSettings.isSongNotificationEnabled());
map.put("autoHide", userSettings.isAutoHidePlayQueue());
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("playQueue","model",map);
}
public void setPlayerService(PlayerService playerService) {

@ -27,7 +27,11 @@ import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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;
import org.springframework.web.servlet.view.RedirectView;
@ -42,16 +46,22 @@ import java.util.Map;
*
* @author Sindre Mehus
*/
public class PlaylistController extends ParameterizableViewController {
@Controller
@RequestMapping("/playlist")
public class PlaylistController {
@Autowired
private SecurityService securityService;
@Autowired
private PlaylistService playlistService;
@Autowired
private SettingsService settingsService;
@Autowired
private PlayerService playerService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
User user = securityService.getCurrentUser(request);
@ -60,7 +70,7 @@ public class PlaylistController extends ParameterizableViewController {
Player player = playerService.getPlayer(request, response);
Playlist playlist = playlistService.getPlaylist(id);
if (playlist == null) {
return new ModelAndView(new RedirectView("notFound.view"));
return new ModelAndView(new RedirectView("notFound"));
}
map.put("playlist", playlist);
@ -69,24 +79,10 @@ public class PlaylistController extends ParameterizableViewController {
map.put("editAllowed", username.equals(playlist.getUsername()) || securityService.isAdmin(username));
map.put("partyMode", userSettings.isPartyModeEnabled());
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("playlist","model",map);
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
}

@ -25,7 +25,10 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.view.RedirectView;
@ -44,29 +47,25 @@ import org.libresonic.player.service.SettingsService;
*
* @author Sindre Mehus
*/
@Controller
@RequestMapping("/playlists")
public class PlaylistsController extends ParameterizableViewController {
@Autowired
private SecurityService securityService;
@Autowired
private PlaylistService playlistService;
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
List<Playlist> playlists = playlistService.getReadablePlaylistsForUser(user.getUsername());
map.put("playlists", playlists);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("playlists","model",map);
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
}

@ -19,34 +19,39 @@
package org.libresonic.player.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.libresonic.player.service.PodcastService;
import org.libresonic.player.service.SecurityService;
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;
import org.libresonic.player.service.PodcastService;
import org.libresonic.player.service.SecurityService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* Controller for the "Podcast channel" page.
*
* @author Sindre Mehus
*/
public class PodcastChannelController extends ParameterizableViewController {
@Controller
@RequestMapping("/podcastChannel")
public class PodcastChannelController {
@Autowired
private PodcastService podcastService;
@Autowired
private SecurityService securityService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
ModelAndView result = super.handleRequestInternal(request, response);
Map<String, Object> map = new HashMap<>();
ModelAndView result = new ModelAndView();
result.addObject("model", map);
int channelId = ServletRequestUtils.getRequiredIntParameter(request, "id");
@ -57,11 +62,4 @@ public class PodcastChannelController extends ParameterizableViewController {
return result;
}
public void setPodcastService(PodcastService podcastService) {
this.podcastService = podcastService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}

@ -18,43 +18,49 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
import java.util.LinkedHashMap;
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.PodcastChannel;
import org.libresonic.player.domain.PodcastEpisode;
import org.libresonic.player.service.PodcastService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Controller for the "Podcast channels" page.
*
* @author Sindre Mehus
*/
public class PodcastChannelsController extends ParameterizableViewController {
@Controller
@RequestMapping("/podcastChannels")
public class PodcastChannelsController {
@Autowired
private PodcastService podcastService;
@Autowired
private SecurityService securityService;
@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>();
ModelAndView result = super.handleRequestInternal(request, response);
Map<String, Object> map = new HashMap<>();
ModelAndView result = new ModelAndView();
result.addObject("model", map);
Map<PodcastChannel, List<PodcastEpisode>> channels = new LinkedHashMap<PodcastChannel, List<PodcastEpisode>>();
Map<Integer, PodcastChannel> channelMap = new HashMap<Integer, PodcastChannel>();
Map<PodcastChannel, List<PodcastEpisode>> channels = new LinkedHashMap<>();
Map<Integer, PodcastChannel> channelMap = new HashMap<>();
for (PodcastChannel channel : podcastService.getAllChannels()) {
channels.put(channel, podcastService.getEpisodes(channel.getId()));
channelMap.put(channel.getId(), channel);
@ -67,15 +73,6 @@ public class PodcastChannelsController extends ParameterizableViewController {
return result;
}
public void setPodcastService(PodcastService podcastService) {
this.podcastService = podcastService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
}

@ -25,37 +25,42 @@ import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
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;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.*;
/**
* Controller for the page used to generate the Podcast XML file.
*
* @author Sindre Mehus
*/
public class PodcastController extends ParameterizableViewController {
@Controller
@RequestMapping("/podcast")
public class PodcastController {
private static final DateFormat RSS_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
@Autowired
private PlaylistService playlistService;
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String url = request.getRequestURL().toString();
String username = securityService.getCurrentUsername(request);
List<Playlist> playlists = playlistService.getReadablePlaylistsForUser(username);
List<Podcast> podcasts = new ArrayList<Podcast>();
List<Podcast> podcasts = new ArrayList<>();
for (Playlist playlist : playlists) {
@ -85,27 +90,16 @@ public class PodcastController extends ParameterizableViewController {
podcasts.add(new Podcast(playlist.getName(), publishDate, enclosureUrl, length, type));
}
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
ModelAndView result = super.handleRequestInternal(request, response);
map.put("url", url);
map.put("podcasts", podcasts);
result.addObject("model", map);
return result;
return new ModelAndView("podcast","model",map);
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
/**
* Contains information about a single Podcast.

@ -19,32 +19,35 @@
*/
package org.libresonic.player.controller;
import org.apache.commons.lang.StringUtils;
import org.libresonic.player.domain.PodcastEpisode;
import org.libresonic.player.domain.PodcastStatus;
import org.libresonic.player.service.PodcastService;
import org.libresonic.player.util.StringUtil;
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.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
/**
* Controller for the "Podcast receiver" page.
*
* @author Sindre Mehus
*/
public class PodcastReceiverAdminController extends AbstractController {
@Controller
@RequestMapping("/podcastReceiverAdmin")
public class PodcastReceiverAdminController {
@Autowired
private PodcastService podcastService;
@Override
@RequestMapping(method = RequestMethod.POST)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Integer channelId = ServletRequestUtils.getIntParameter(request, "channelId");
@ -93,7 +96,4 @@ public class PodcastReceiverAdminController extends AbstractController {
}
}
public void setPodcastService(PodcastService podcastService) {
this.podcastService = podcastService;
}
}

@ -19,11 +19,6 @@
*/
package org.libresonic.player.controller;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
@ -31,17 +26,26 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
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.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
/**
* A proxy for external HTTP requests.
*
* @author Sindre Mehus
*/
public class ProxyController implements Controller {
@Controller
@RequestMapping("/proxy")
public class ProxyController {
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
String url = ServletRequestUtils.getRequiredStringParameter(request, "url");

@ -19,124 +19,46 @@
*/
package org.libresonic.player.controller;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import org.libresonic.restapi.AlbumID3;
import org.libresonic.restapi.AlbumList;
import org.libresonic.restapi.AlbumList2;
import org.libresonic.restapi.AlbumWithSongsID3;
import org.libresonic.restapi.ArtistID3;
import org.libresonic.restapi.ArtistInfo;
import org.libresonic.restapi.ArtistInfo2;
import org.libresonic.restapi.ArtistWithAlbumsID3;
import org.libresonic.restapi.ArtistsID3;
import org.libresonic.restapi.Bookmarks;
import org.libresonic.restapi.ChatMessage;
import org.libresonic.restapi.ChatMessages;
import org.libresonic.restapi.Child;
import org.libresonic.restapi.Directory;
import org.libresonic.restapi.Genres;
import org.libresonic.restapi.Index;
import org.libresonic.restapi.IndexID3;
import org.libresonic.restapi.Indexes;
import org.libresonic.restapi.InternetRadioStation;
import org.libresonic.restapi.InternetRadioStations;
import org.libresonic.restapi.JukeboxPlaylist;
import org.libresonic.restapi.JukeboxStatus;
import org.libresonic.restapi.Lyrics;
import org.libresonic.restapi.MediaType;
import org.libresonic.restapi.MusicFolders;
import org.libresonic.restapi.NewestPodcasts;
import org.libresonic.restapi.NowPlaying;
import org.libresonic.restapi.NowPlayingEntry;
import org.libresonic.restapi.PlaylistWithSongs;
import org.libresonic.restapi.Playlists;
import org.libresonic.restapi.PodcastStatus;
import org.libresonic.restapi.Podcasts;
import org.libresonic.restapi.Response;
import org.libresonic.restapi.SearchResult2;
import org.libresonic.restapi.SearchResult3;
import org.libresonic.restapi.Shares;
import org.libresonic.restapi.SimilarSongs;
import org.libresonic.restapi.SimilarSongs2;
import org.libresonic.restapi.Songs;
import org.libresonic.restapi.Starred;
import org.libresonic.restapi.Starred2;
import org.libresonic.restapi.TopSongs;
import org.libresonic.restapi.Users;
import org.libresonic.restapi.Videos;
import org.libresonic.player.Logger;
import org.libresonic.player.ajax.ChatService;
import org.libresonic.player.ajax.LyricsInfo;
import org.libresonic.player.ajax.LyricsService;
import org.libresonic.player.ajax.PlayQueueService;
import org.libresonic.player.command.UserSettingsCommand;
import org.libresonic.player.dao.AlbumDao;
import org.libresonic.player.dao.ArtistDao;
import org.libresonic.player.dao.BookmarkDao;
import org.libresonic.player.dao.MediaFileDao;
import org.libresonic.player.dao.PlayQueueDao;
import org.libresonic.player.domain.Album;
import org.libresonic.player.dao.*;
import org.libresonic.player.domain.*;
import org.libresonic.player.domain.Artist;
import org.libresonic.player.domain.ArtistBio;
import org.libresonic.player.domain.Bookmark;
import org.libresonic.player.domain.Genre;
import org.libresonic.player.domain.InternetRadio;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.MusicFolderContent;
import org.libresonic.player.domain.MusicIndex;
import org.libresonic.player.domain.PlayQueue;
import org.libresonic.player.domain.PlayStatus;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.PlayerTechnology;
import org.libresonic.player.domain.Playlist;
import org.libresonic.player.domain.PodcastChannel;
import org.libresonic.player.domain.PodcastEpisode;
import org.libresonic.player.domain.RandomSearchCriteria;
import org.libresonic.player.domain.SavedPlayQueue;
import org.libresonic.player.domain.SearchCriteria;
import org.libresonic.player.domain.SearchResult;
import org.libresonic.player.domain.Share;
import org.libresonic.player.domain.TranscodeScheme;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.AudioScrobblerService;
import org.libresonic.player.service.JukeboxService;
import org.libresonic.player.service.LastFmService;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.MusicIndexService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.PodcastService;
import org.libresonic.player.service.RatingService;
import org.libresonic.player.service.SearchService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.ShareService;
import org.libresonic.player.service.StatusService;
import org.libresonic.player.service.TranscodingService;
import org.libresonic.player.service.*;
import org.libresonic.player.util.Pair;
import org.libresonic.player.util.StringUtil;
import org.libresonic.player.util.Util;
import org.libresonic.restapi.*;
import org.libresonic.restapi.Genres;
import org.libresonic.restapi.PodcastStatus;
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.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static org.libresonic.player.security.RESTRequestParameterProcessingFilter.decrypt;
import static org.springframework.web.bind.ServletRequestUtils.*;
@ -150,44 +72,76 @@ import static org.springframework.web.bind.ServletRequestUtils.*;
*
* @author Sindre Mehus
*/
public class RESTController extends MultiActionController {
@Controller
public class RESTController {
private static final Logger LOG = Logger.getLogger(RESTController.class);
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@Autowired
private PlayerService playerService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private LastFmService lastFmService;
@Autowired
private MusicIndexService musicIndexService;
@Autowired
private TranscodingService transcodingService;
@Autowired
private DownloadController downloadController;
@Autowired
private CoverArtController coverArtController;
@Autowired
private AvatarController avatarController;
@Autowired
private UserSettingsController userSettingsController;
@Autowired
private LeftController leftController;
@Autowired
private StatusService statusService;
@Autowired
private StreamController streamController;
@Autowired
private HLSController hlsController;
@Autowired
private ShareService shareService;
@Autowired
private PlaylistService playlistService;
@Autowired
private ChatService chatService;
@Autowired
private LyricsService lyricsService;
@Autowired
private PlayQueueService playQueueService;
@Autowired
private JukeboxService jukeboxService;
@Autowired
private AudioScrobblerService audioScrobblerService;
@Autowired
private PodcastService podcastService;
@Autowired
private RatingService ratingService;
@Autowired
private SearchService searchService;
@Autowired
private MediaFileDao mediaFileDao;
@Autowired
private ArtistDao artistDao;
@Autowired
private AlbumDao albumDao;
@Autowired
private BookmarkDao bookmarkDao;
@Autowired
private PlayQueueDao playQueueDao;
private final Map<BookmarkKey, Bookmark> bookmarkCache = new ConcurrentHashMap<BookmarkKey, Bookmark>();
private final JAXBWriter jaxbWriter = new JAXBWriter();
@PostConstruct
public void init() {
refreshBookmarkCache();
}
@ -199,13 +153,13 @@ public class RESTController extends MultiActionController {
}
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/ping", method = RequestMethod.GET)
public void ping(HttpServletRequest request, HttpServletResponse response) throws Exception {
Response res = createResponse();
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getMusicFolders", method = RequestMethod.GET)
public void getMusicFolders(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -222,7 +176,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getIndexes", method = RequestMethod.GET)
public void getIndexes(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Response res = createResponse();
@ -292,7 +246,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getGenres", method = RequestMethod.GET)
public void getGenres(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Genres genres = new Genres();
@ -309,7 +263,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getSongsByGenre", method = RequestMethod.GET)
public void getSongsByGenre(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -332,7 +286,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getArtists", method = RequestMethod.GET)
public void getArtists(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -357,7 +311,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getSimilarSongs", method = RequestMethod.GET)
public void getSimilarSongs(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -384,7 +338,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getSimilarSongs2", method = RequestMethod.GET)
public void getSimilarSongs2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -412,7 +366,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getTopSongs", method = RequestMethod.GET)
public void getTopSongs(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -434,7 +388,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getArtistInfo", method = RequestMethod.GET)
public void getArtistInfo(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -470,7 +424,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getArtistInfo2", method = RequestMethod.GET)
public void getArtistInfo2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -527,6 +481,7 @@ public class RESTController extends MultiActionController {
return result;
}
@RequestMapping(value = "/rest/getArtist", method = RequestMethod.GET)
public void getArtist(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -589,7 +544,7 @@ public class RESTController extends MultiActionController {
return jaxbPlaylist;
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getAlbum", method = RequestMethod.GET)
public void getAlbum(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -612,7 +567,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getSong", method = RequestMethod.GET)
public void getSong(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -634,7 +589,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getMusicDirectory", method = RequestMethod.GET)
public void getMusicDirectory(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -678,7 +633,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@Deprecated
@RequestMapping(value = "/rest/search", method = RequestMethod.GET)
public void search(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -722,7 +677,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/search2", method = RequestMethod.GET)
public void search2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -761,7 +716,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/search3", method = RequestMethod.GET)
public void search3(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -800,7 +755,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getPlaylists", method = RequestMethod.GET)
public void getPlaylists(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -826,6 +781,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@RequestMapping(value = "/rest/getPlaylist", method = RequestMethod.GET)
public void getPlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -854,7 +810,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/jukeboxControl", method = RequestMethod.GET)
public void jukeboxControl(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request, true);
@ -933,7 +889,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/createPlaylist", method = RequestMethod.GET)
public void createPlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request, true);
String username = securityService.getCurrentUsername(request);
@ -978,7 +934,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/updatePlaylist", method = RequestMethod.GET)
public void updatePlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request, true);
String username = securityService.getCurrentUsername(request);
@ -1046,7 +1002,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/deletePlaylist", method = RequestMethod.GET)
public void deletePlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request, true);
String username = securityService.getCurrentUsername(request);
@ -1066,7 +1022,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getAlbumList", method = RequestMethod.GET)
public void getAlbumList(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1117,7 +1073,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getAlbumList2", method = RequestMethod.GET)
public void getAlbumList2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -1161,7 +1117,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getRandomSongs", method = RequestMethod.GET)
public void getRandomSongs(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1185,7 +1141,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getVideos", method = RequestMethod.GET)
public void getVideos(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1204,7 +1160,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getNowPlaying", method = RequestMethod.GET)
public void getNowPlaying(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
NowPlaying result = new NowPlaying();
@ -1357,6 +1313,7 @@ public class RESTController extends MultiActionController {
return null;
}
@RequestMapping(value = "/rest/download", method = RequestMethod.GET)
public ModelAndView download(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1380,6 +1337,7 @@ public class RESTController extends MultiActionController {
return downloadController.handleRequest(request, response);
}
@RequestMapping(value = "/rest/stream", method = RequestMethod.GET)
public ModelAndView stream(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1392,6 +1350,7 @@ public class RESTController extends MultiActionController {
return null;
}
@RequestMapping(value = "/rest/hls", method = RequestMethod.GET)
public ModelAndView hls(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1413,7 +1372,7 @@ public class RESTController extends MultiActionController {
return null;
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/scrobble", method = RequestMethod.GET)
public void scrobble(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -1446,12 +1405,12 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/star", method = RequestMethod.GET)
public void star(HttpServletRequest request, HttpServletResponse response) throws Exception {
starOrUnstar(request, response, true);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/unstar", method = RequestMethod.GET)
public void unstar(HttpServletRequest request, HttpServletResponse response) throws Exception {
starOrUnstar(request, response, false);
}
@ -1500,7 +1459,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getStarred", method = RequestMethod.GET)
public void getStarred(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1523,7 +1482,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getStarred2", method = RequestMethod.GET)
public void getStarred2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1546,7 +1505,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getPodcasts", method = RequestMethod.GET)
public void getPodcasts(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1584,7 +1543,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getNewestPodcasts", method = RequestMethod.GET)
public void getNewestPodcasts(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1621,7 +1580,7 @@ public class RESTController extends MultiActionController {
return e;
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/refreshPodcasts", method = RequestMethod.GET)
public void refreshPodcasts(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1633,7 +1592,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/createPodcastChannel", method = RequestMethod.GET)
public void createPodcastChannel(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1647,7 +1606,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/deletePodcastChannel", method = RequestMethod.GET)
public void deletePodcastChannel(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1661,7 +1620,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/deletePodcastEpisode", method = RequestMethod.GET)
public void deletePodcastEpisode(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1675,7 +1634,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/downloadPodcastEpisode", method = RequestMethod.GET)
public void downloadPodcastEpisode(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1695,7 +1654,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getInternetRadioStations", method = RequestMethod.GET)
public void getInternetRadioStations(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -1713,7 +1672,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getBookmarks", method = RequestMethod.GET)
public void getBookmarks(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1738,7 +1697,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/createBookmark", method = RequestMethod.GET)
public void createBookmark(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -1753,7 +1712,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/deleteBookmark", method = RequestMethod.GET)
public void deleteBookmark(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -1765,7 +1724,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getPlayQueue", method = RequestMethod.GET)
public void getPlayQueue(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -1796,7 +1755,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/savePlayQueue", method = RequestMethod.GET)
public void savePlayQueue(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
@ -1816,7 +1775,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getShares", method = RequestMethod.GET)
public void getShares(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1838,7 +1797,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/createShare", method = RequestMethod.GET)
public void createShare(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
@ -1883,7 +1842,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/deleteShare", method = RequestMethod.GET)
public void deleteShare(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1903,7 +1862,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/updateShare", method = RequestMethod.GET)
public void updateShare(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -1976,19 +1935,19 @@ public class RESTController extends MultiActionController {
return result;
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getCoverArt", method = RequestMethod.GET)
public ModelAndView getCoverArt(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
return coverArtController.handleRequest(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getAvatar", method = RequestMethod.GET)
public ModelAndView getAvatar(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
return avatarController.handleRequest(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/changePassword", method = RequestMethod.GET)
public void changePassword(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -2012,7 +1971,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getUser", method = RequestMethod.GET)
public void getUser(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -2035,7 +1994,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getUsers", method = RequestMethod.GET)
public void getUsers(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
@ -2086,7 +2045,7 @@ public class RESTController extends MultiActionController {
return result;
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/createUser", method = RequestMethod.GET)
public void createUser(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -2122,7 +2081,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/updateUser", method = RequestMethod.GET)
public void updateUser(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -2180,7 +2139,7 @@ public class RESTController extends MultiActionController {
return request.getParameter(name) != null;
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/deleteUser", method = RequestMethod.GET)
public void deleteUser(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
@ -2200,7 +2159,7 @@ public class RESTController extends MultiActionController {
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getChatMessages", method = RequestMethod.GET)
public void getChatMessages(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
long since = getLongParameter(request, "since", 0L);
@ -2221,14 +2180,14 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/addChatMessage", method = RequestMethod.GET)
public void addChatMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
chatService.doAddMessage(getRequiredStringParameter(request, "message"), request);
writeEmptyResponse(request, response);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/getLyrics", method = RequestMethod.GET)
public void getLyrics(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String artist = request.getParameter("artist");
@ -2245,7 +2204,7 @@ public class RESTController extends MultiActionController {
jaxbWriter.writeResponse(request, response, res);
}
@SuppressWarnings("UnusedDeclaration")
@RequestMapping(value = "/rest/setRating", method = RequestMethod.GET)
public void setRating(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Integer rating = getRequiredIntParameter(request, "rating");
@ -2342,125 +2301,6 @@ public class RESTController extends MultiActionController {
return !players.isEmpty() ? players.get(0).getId() : null;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setTranscodingService(TranscodingService transcodingService) {
this.transcodingService = transcodingService;
}
public void setDownloadController(DownloadController downloadController) {
this.downloadController = downloadController;
}
public void setCoverArtController(CoverArtController coverArtController) {
this.coverArtController = coverArtController;
}
public void setUserSettingsController(UserSettingsController userSettingsController) {
this.userSettingsController = userSettingsController;
}
public void setLeftController(LeftController leftController) {
this.leftController = leftController;
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setStreamController(StreamController streamController) {
this.streamController = streamController;
}
public void setHlsController(HLSController hlsController) {
this.hlsController = hlsController;
}
public void setChatService(ChatService chatService) {
this.chatService = chatService;
}
public void setLyricsService(LyricsService lyricsService) {
this.lyricsService = lyricsService;
}
public void setPlayQueueService(PlayQueueService playQueueService) {
this.playQueueService = playQueueService;
}
public void setJukeboxService(JukeboxService jukeboxService) {
this.jukeboxService = jukeboxService;
}
public void setAudioScrobblerService(AudioScrobblerService audioScrobblerService) {
this.audioScrobblerService = audioScrobblerService;
}
public void setPodcastService(PodcastService podcastService) {
this.podcastService = podcastService;
}
public void setRatingService(RatingService ratingService) {
this.ratingService = ratingService;
}
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
public void setShareService(ShareService shareService) {
this.shareService = shareService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setAvatarController(AvatarController avatarController) {
this.avatarController = avatarController;
}
public void setArtistDao(ArtistDao artistDao) {
this.artistDao = artistDao;
}
public void setAlbumDao(AlbumDao albumDao) {
this.albumDao = albumDao;
}
public void setMediaFileDao(MediaFileDao mediaFileDao) {
this.mediaFileDao = mediaFileDao;
}
public void setMusicIndexService(MusicIndexService musicIndexService) {
this.musicIndexService = musicIndexService;
}
public void setBookmarkDao(BookmarkDao bookmarkDao) {
this.bookmarkDao = bookmarkDao;
}
public void setLastFmService(LastFmService lastFmService) {
this.lastFmService = lastFmService;
}
public void setPlayQueueDao(PlayQueueDao playQueueDao) {
this.playQueueDao = playQueueDao;
}
public enum ErrorCode {

@ -1,69 +1,48 @@
/*
This file is part of Libresonic.
Libresonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Libresonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2016 (C) Libresonic Authors
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
*/
package org.libresonic.player.controller;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.tanesha.recaptcha.ReCaptcha;
import net.tanesha.recaptcha.ReCaptchaFactory;
import net.tanesha.recaptcha.ReCaptchaResponse;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.Playlist;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.bind.ServletRequestUtils;
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.multiaction.MultiActionController;
import org.springframework.web.servlet.view.RedirectView;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* Multi-controller used for simple pages.
*
* @author Sindre Mehus
* Spring MVC Controller that serves the login page.
*/
public class MultiController extends MultiActionController {
@Controller
@RequestMapping("/recover")
public class RecoverController {
private static final Logger LOG = Logger.getLogger(MultiController.class);
private SecurityService securityService;
private static final Logger LOG = Logger.getLogger(RecoverController.class);
@Autowired
private SettingsService settingsService;
private PlaylistService playlistService;
@Autowired
private SecurityService securityService;
@RequestMapping(method = {RequestMethod.GET})
public ModelAndView recover(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
@ -107,9 +86,20 @@ public class MultiController extends MultiActionController {
return new ModelAndView("recover", "model", map);
}
private User getUserByUsernameOrEmail(String usernameOrEmail) {
if (usernameOrEmail != null) {
User user = securityService.getUserByName(usernameOrEmail);
if (user != null) {
return user;
}
return securityService.getUserByEmail(usernameOrEmail);
}
return null;
}
/*
* e-mail user new password via configured Smtp server
*/
* e-mail user new password via configured Smtp server
*/
private boolean emailPassword(String password, String username, String email) {
/* Default to protocol smtp when SmtpEncryption is set to "None" */
String prot = "smtp";
@ -169,103 +159,4 @@ public class MultiController extends MultiActionController {
}
}
private User getUserByUsernameOrEmail(String usernameOrEmail) {
if (usernameOrEmail != null) {
User user = securityService.getUserByName(usernameOrEmail);
if (user != null) {
return user;
}
return securityService.getUserByEmail(usernameOrEmail);
}
return null;
}
public ModelAndView accessDenied(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("accessDenied");
}
public ModelAndView notFound(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("notFound");
}
public ModelAndView gettingStarted(HttpServletRequest request, HttpServletResponse response) {
updatePortAndContextPath(request);
if (request.getParameter("hide") != null) {
settingsService.setGettingStartedEnabled(false);
settingsService.save();
return new ModelAndView(new RedirectView("home.view"));
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("runningAsRoot", "root".equals(System.getProperty("user.name")));
return new ModelAndView("gettingStarted", "model", map);
}
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
updatePortAndContextPath(request);
UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));
Map<String, Object> map = new HashMap<String, Object>();
map.put("showRight", userSettings.isShowNowPlayingEnabled() || userSettings.isShowChatEnabled());
map.put("autoHidePlayQueue", userSettings.isAutoHidePlayQueue());
map.put("listReloadDelay", userSettings.getListReloadDelay());
map.put("keyboardShortcutsEnabled", userSettings.isKeyboardShortcutsEnabled());
map.put("showSideBar", userSettings.isShowSideBar());
map.put("brand", settingsService.getBrand());
return new ModelAndView("index", "model", map);
}
public ModelAndView exportPlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Playlist playlist = playlistService.getPlaylist(id);
if (!playlistService.isReadAllowed(playlist, securityService.getCurrentUsername(request))) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return null;
}
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=\"" + StringUtil.fileSystemSafe(playlist.getName()) + ".m3u8\"");
playlistService.exportPlaylist(id, response.getOutputStream());
return null;
}
private void updatePortAndContextPath(HttpServletRequest request) {
int port = Integer.parseInt(System.getProperty("libresonic.port", String.valueOf(request.getLocalPort())));
int httpsPort = Integer.parseInt(System.getProperty("libresonic.httpsPort", "0"));
String contextPath = request.getContextPath().replace("/", "");
if (settingsService.getPort() != port) {
settingsService.setPort(port);
settingsService.save();
}
if (settingsService.getHttpsPort() != httpsPort) {
settingsService.setHttpsPort(httpsPort);
settingsService.save();
}
if (!ObjectUtils.equals(settingsService.getUrlRedirectContextPath(), contextPath)) {
settingsService.setUrlRedirectContextPath(contextPath);
settingsService.save();
}
}
public ModelAndView test(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("test");
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
}

@ -19,35 +19,40 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
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.UserSettings;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.VersionService;
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 java.util.HashMap;
import java.util.Map;
/**
* Controller for the right frame.
*
* @author Sindre Mehus
*/
public class RightController extends ParameterizableViewController {
@Controller
@RequestMapping("/right")
public class RightController {
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@Autowired
private VersionService versionService;
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
ModelAndView result = super.handleRequestInternal(request, response);
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<>();
ModelAndView result = new ModelAndView("right");
UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));
if (userSettings.isFinalVersionNotificationEnabled() && versionService.isNewFinalVersionAvailable()) {
@ -68,15 +73,4 @@ public class RightController extends ParameterizableViewController {
return result;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setVersionService(VersionService versionService) {
this.versionService = versionService;
}
}

@ -19,28 +19,33 @@
*/
package org.libresonic.player.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.util.StringUtil;
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.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.util.StringUtil;
import javax.servlet.http.HttpServletRequest;
/**
* Controller for updating music file metadata.
*
* @author Sindre Mehus
*/
public class SetMusicFileInfoController extends AbstractController {
@Controller
@RequestMapping("/setMusicFileInfo")
public class SetMusicFileInfoController {
@Autowired
private MediaFileService mediaFileService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
String action = request.getParameter("action");
@ -55,7 +60,4 @@ public class SetMusicFileInfoController extends AbstractController {
return new ModelAndView(new RedirectView(url));
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -19,53 +19,48 @@
*/
package org.libresonic.player.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.RatingService;
import org.libresonic.player.service.SecurityService;
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.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
/**
* Controller for updating music file ratings.
*
* @author Sindre Mehus
*/
public class SetRatingController extends AbstractController {
@Controller
@RequestMapping("/setRating")
public class SetRatingController {
@Autowired
private RatingService ratingService;
@Autowired
private SecurityService securityService;
@Autowired
private MediaFileService mediaFileService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Integer rating = ServletRequestUtils.getIntParameter(request, "rating");
if (rating == 0) {
rating = null;
}
MediaFile mediaFile = mediaFileService.getMediaFile(id);
String username = securityService.getCurrentUsername(request);
ratingService.setRatingForUser(username, mediaFile, rating);
return new ModelAndView(new RedirectView("main.view?id=" + id));
}
public void setRatingService(RatingService ratingService) {
this.ratingService = ratingService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -19,35 +19,41 @@
*/
package org.libresonic.player.controller;
import org.libresonic.player.domain.*;
import org.libresonic.player.service.*;
import org.springframework.web.servlet.*;
import org.springframework.web.servlet.view.*;
import org.springframework.web.servlet.mvc.*;
import javax.servlet.http.*;
import org.libresonic.player.domain.User;
import org.libresonic.player.service.SecurityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestAttribute;
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.AbstractController;
import org.springframework.web.servlet.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Controller for the main settings page.
*
* @author Sindre Mehus
*/
public class SettingsController extends AbstractController {
@Controller
@RequestMapping("/settings")
public class SettingsController {
@Autowired
private SecurityService securityService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
User user = securityService.getCurrentUser(request);
// Redirect to music folder settings if admin.
String view = user.isAdminRole() ? "musicFolderSettings.view" : "personalSettings.view";
String view = user.isAdminRole() ? "musicFolderSettings" : "personalSettings";
return new ModelAndView(new RedirectView(view));
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}

@ -23,39 +23,42 @@ import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.PlayQueue;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.Share;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.ShareService;
import org.libresonic.player.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
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.multiaction.MultiActionController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* Controller for sharing music on Twitter, Facebook etc.
*
* @author Sindre Mehus
*/
public class ShareManagementController extends MultiActionController {
@Controller
@RequestMapping("/createShare")
public class ShareManagementController {
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SettingsService settingsService;
@Autowired
private ShareService shareService;
@Autowired
private PlayerService playerService;
@Autowired
private PlaylistService playlistService;
@Autowired
private SecurityService securityService;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView createShare(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<MediaFile> files = getMediaFiles(request);
@ -94,7 +97,7 @@ public class ShareManagementController extends MultiActionController {
String playerId = request.getParameter("player");
Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
List<MediaFile> result = new ArrayList<MediaFile>();
List<MediaFile> result = new ArrayList<>();
if (id != null) {
MediaFile album = mediaFileService.getMediaFile(id);
@ -121,27 +124,4 @@ public class ShareManagementController extends MultiActionController {
return result;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setShareService(ShareService shareService) {
this.shareService = shareService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
}

@ -20,21 +20,19 @@
package org.libresonic.player.controller;
import org.libresonic.player.dao.MediaFileDao;
import org.libresonic.player.domain.CoverArtScheme;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.domain.*;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -45,17 +43,24 @@ import java.util.Map;
*
* @author Sindre Mehus
*/
public class StarredController extends ParameterizableViewController {
@Controller
@RequestMapping("/starred")
public class StarredController {
@Autowired
private PlayerService playerService;
@Autowired
private MediaFileDao mediaFileDao;
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
@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>();
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
String username = user.getUsername();
@ -69,8 +74,8 @@ public class StarredController extends ParameterizableViewController {
mediaFileService.populateStarredDate(albums, username);
mediaFileService.populateStarredDate(files, username);
List<MediaFile> songs = new ArrayList<MediaFile>();
List<MediaFile> videos = new ArrayList<MediaFile>();
List<MediaFile> songs = new ArrayList<>();
List<MediaFile> videos = new ArrayList<>();
for (MediaFile file : files) {
(file.isVideo() ? videos : songs).add(file);
}
@ -83,28 +88,7 @@ public class StarredController extends ParameterizableViewController {
map.put("albums", albums);
map.put("songs", songs);
map.put("videos", videos);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
return new ModelAndView("starred","model",map);
}
public void setMediaFileDao(MediaFileDao mediaFileDao) {
this.mediaFileDao = mediaFileDao;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -27,6 +27,10 @@ import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.xy.*;
import org.jfree.data.*;
import org.jfree.data.time.*;
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.*;
import javax.servlet.http.*;
@ -39,13 +43,17 @@ import java.util.List;
*
* @author Sindre Mehus
*/
@Controller
@RequestMapping("/statusChart")
public class StatusChartController extends AbstractChartController {
@Autowired
private StatusService statusService;
public static final int IMAGE_WIDTH = 350;
public static final int IMAGE_HEIGHT = 150;
@RequestMapping(method = RequestMethod.GET)
public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
String type = request.getParameter("type");
int index = Integer.parseInt(request.getParameter("index"));
@ -144,7 +152,4 @@ public class StatusChartController extends AbstractChartController {
return null;
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
}

@ -24,37 +24,39 @@ import org.libresonic.player.domain.TransferStatus;
import org.libresonic.player.service.StatusService;
import org.libresonic.player.util.FileUtil;
import org.libresonic.player.util.StringUtil;
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;
import org.springframework.web.servlet.support.RequestContextUtils;
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.Locale;
import java.util.Map;
import java.util.*;
/**
* Controller for the status page.
*
* @author Sindre Mehus
*/
public class StatusController extends ParameterizableViewController {
@Controller
@RequestMapping("/status")
public class StatusController {
@Autowired
private StatusService statusService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
List<TransferStatus> streamStatuses = statusService.getAllStreamStatuses();
List<TransferStatus> downloadStatuses = statusService.getAllDownloadStatuses();
List<TransferStatus> uploadStatuses = statusService.getAllUploadStatuses();
Locale locale = RequestContextUtils.getLocale(request);
List<TransferStatusHolder> transferStatuses = new ArrayList<TransferStatusHolder>();
List<TransferStatusHolder> transferStatuses = new ArrayList<>();
for (int i = 0; i < streamStatuses.size(); i++) {
long minutesAgo = streamStatuses.get(i).getMillisSinceLastUpdate() / 1000L / 60L;
@ -73,16 +75,11 @@ public class StatusController extends ParameterizableViewController {
map.put("chartWidth", StatusChartController.IMAGE_WIDTH);
map.put("chartHeight", StatusChartController.IMAGE_HEIGHT);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("status","model",map);
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public static class TransferStatusHolder {
private static class TransferStatusHolder {
private TransferStatus transferStatus;
private boolean isStream;
private boolean isDownload;
@ -90,8 +87,8 @@ public class StatusController extends ParameterizableViewController {
private int index;
private Locale locale;
public TransferStatusHolder(TransferStatus transferStatus, boolean isStream, boolean isDownload, boolean isUpload,
int index, Locale locale) {
TransferStatusHolder(TransferStatus transferStatus, boolean isStream, boolean isDownload, boolean isUpload,
int index, Locale locale) {
this.transferStatus = transferStatus;
this.isStream = isStream;
this.isDownload = isDownload;

@ -30,10 +30,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestBindingException;
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.Controller;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.MediaFile;
@ -65,20 +68,32 @@ import org.libresonic.player.util.Util;
*
* @author Sindre Mehus
*/
public class StreamController implements Controller {
@Controller
@RequestMapping("/stream/**")
public class StreamController {
private static final Logger LOG = Logger.getLogger(StreamController.class);
@Autowired
private StatusService statusService;
@Autowired
private PlayerService playerService;
@Autowired
private PlaylistService playlistService;
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
@Autowired
private TranscodingService transcodingService;
@Autowired
private AudioScrobblerService audioScrobblerService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SearchService searchService;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
TransferStatus status = null;
@ -410,39 +425,4 @@ public class StreamController implements Controller {
out.flush();
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setTranscodingService(TranscodingService transcodingService) {
this.transcodingService = transcodingService;
}
public void setAudioScrobblerService(AudioScrobblerService audioScrobblerService) {
this.audioScrobblerService = audioScrobblerService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
}

@ -0,0 +1,28 @@
package org.libresonic.player.controller;
import org.libresonic.player.Logger;
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;
/**
* Spring MVC Controller that serves the login page.
*/
@Controller
@RequestMapping("/test")
public class TestController {
private static final Logger LOG = Logger.getLogger(TestController.class);
@RequestMapping(method = {RequestMethod.GET})
public ModelAndView test(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("test");
}
}

@ -19,33 +19,39 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
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.AvatarScheme;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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.util.HashMap;
import java.util.Map;
/**
* Controller for the top frame.
*
* @author Sindre Mehus
*/
public class TopController extends ParameterizableViewController {
@Controller
@RequestMapping("/top")
public class TopController {
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
@ -53,17 +59,6 @@ public class TopController extends ParameterizableViewController {
map.put("user", user);
map.put("showSideBar", userSettings.isShowSideBar());
map.put("showAvatar", userSettings.getAvatarScheme() != AvatarScheme.NONE);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
return new ModelAndView("top","model", map);
}
}

@ -19,20 +19,33 @@
*/
package org.libresonic.player.controller;
import org.libresonic.player.*;
import org.libresonic.player.domain.*;
import org.libresonic.player.upload.*;
import org.libresonic.player.service.*;
import org.libresonic.player.util.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.io.*;
import org.apache.tools.zip.*;
import org.springframework.web.servlet.*;
import org.springframework.web.servlet.mvc.*;
import javax.servlet.http.*;
import java.io.*;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.IOUtils;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.TransferStatus;
import org.libresonic.player.domain.User;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.StatusService;
import org.libresonic.player.upload.MonitoredDiskFileItemFactory;
import org.libresonic.player.upload.UploadListener;
import org.libresonic.player.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
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.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
/**
@ -40,22 +53,28 @@ import java.util.*;
*
* @author Sindre Mehus
*/
public class UploadController extends ParameterizableViewController {
@org.springframework.stereotype.Controller
@RequestMapping("/upload")
public class UploadController {
private static final Logger LOG = Logger.getLogger(UploadController.class);
@Autowired
private SecurityService securityService;
@Autowired
private PlayerService playerService;
@Autowired
private StatusService statusService;
@Autowired
private SettingsService settingsService;
public static final String UPLOAD_STATUS = "uploadStatus";
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
List<File> uploadedFiles = new ArrayList<File>();
List<File> unzippedFiles = new ArrayList<File>();
Map<String, Object> map = new HashMap<>();
List<File> uploadedFiles = new ArrayList<>();
List<File> unzippedFiles = new ArrayList<>();
TransferStatus status = null;
try {
@ -139,9 +158,7 @@ public class UploadController extends ParameterizableViewController {
map.put("uploadedFiles", uploadedFiles);
map.put("unzippedFiles", unzippedFiles);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("upload","model",map);
}
private void unzip(File file, List<File> unzippedFiles) throws Exception {
@ -196,21 +213,9 @@ public class UploadController extends ParameterizableViewController {
}
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setStatusService(StatusService statusService) {
this.statusService = statusService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
/**
* Receives callbacks as the file upload progresses.

@ -39,6 +39,10 @@ import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
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.libresonic.player.domain.User;
@ -49,14 +53,18 @@ import org.libresonic.player.service.SecurityService;
*
* @author Sindre Mehus
*/
@Controller
@RequestMapping("/userChart")
public class UserChartController extends AbstractChartController {
@Autowired
private SecurityService securityService;
public static final int IMAGE_WIDTH = 400;
public static final int IMAGE_MIN_HEIGHT = 200;
private static final long BYTES_PER_MB = 1024L * 1024L;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
String type = request.getParameter("type");
CategoryDataset dataset = createDataset(type);
@ -140,7 +148,4 @@ public class UserChartController extends AbstractChartController {
return chart;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}

@ -19,17 +19,6 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.User;
import org.libresonic.player.service.MediaFileService;
@ -37,23 +26,41 @@ import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
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.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Controller for the page used to play videos.
*
* @author Sindre Mehus
*/
public class VideoPlayerController extends ParameterizableViewController {
@Controller
@RequestMapping("/videoPlayer")
public class VideoPlayerController {
public static final int DEFAULT_BIT_RATE = 2000;
public static final int[] BIT_RATES = {200, 300, 400, 500, 700, 1000, 1200, 1500, 2000, 3000, 5000};
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SettingsService settingsService;
@Autowired
private PlayerService playerService;
@Autowired
private SecurityService securityService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
@ -87,9 +94,7 @@ public class VideoPlayerController extends ParameterizableViewController {
map.put("defaultBitRate", DEFAULT_BIT_RATE);
map.put("user", user);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("videoPlayer", "model", map);
}
public static Map<String, Integer> createSkipOffsets(int durationSeconds) {
@ -100,19 +105,4 @@ public class VideoPlayerController extends ParameterizableViewController {
return result;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}

@ -1,252 +0,0 @@
/*
This file is part of Libresonic.
Libresonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Libresonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2016 (C) Libresonic Authors
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
*/
package org.libresonic.player.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.MusicIndex;
import org.libresonic.player.domain.PlayQueue;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.RandomSearchCriteria;
import org.libresonic.player.domain.SearchCriteria;
import org.libresonic.player.domain.SearchResult;
import org.libresonic.player.domain.User;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.MusicIndexService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SearchService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
/**
* Multi-controller used for wap pages.
*
* @author Sindre Mehus
*/
public class WapController extends MultiActionController {
private SettingsService settingsService;
private PlayerService playerService;
private PlaylistService playlistService;
private SecurityService securityService;
private MusicIndexService musicIndexService;
private MediaFileService mediaFileService;
private SearchService searchService;
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
return wap(request, response);
}
public ModelAndView wap(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String username = securityService.getCurrentUsername(request);
List<MusicFolder> folders = settingsService.getMusicFoldersForUser(username);
if (folders.isEmpty()) {
map.put("noMusic", true);
} else {
SortedMap<MusicIndex, List<MusicIndex.SortableArtistWithMediaFiles>> allArtists = musicIndexService.getIndexedArtists(folders, false);
// If an index is given as parameter, only show music files for this index.
String index = request.getParameter("index");
if (index != null) {
List<MusicIndex.SortableArtistWithMediaFiles> artists = allArtists.get(new MusicIndex(index));
if (artists == null) {
map.put("noMusic", true);
} else {
map.put("artists", artists);
}
}
// Otherwise, list all indexes.
else {
map.put("indexes", allArtists.keySet());
}
}
return new ModelAndView("wap/index", "model", map);
}
public ModelAndView browse(HttpServletRequest request, HttpServletResponse response) throws Exception {
String path = request.getParameter("path");
MediaFile parent = mediaFileService.getMediaFile(path);
// Create array of file(s) to display.
List<MediaFile> children;
if (parent.isDirectory()) {
children = mediaFileService.getChildrenOf(parent, true, true, true);
} else {
children = new ArrayList<MediaFile>();
children.add(parent);
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("parent", parent);
map.put("children", children);
map.put("user", securityService.getCurrentUser(request));
return new ModelAndView("wap/browse", "model", map);
}
public ModelAndView playlist(HttpServletRequest request, HttpServletResponse response) throws Exception {
// Create array of players to control. If the "player" attribute is set for this session,
// only the player with this ID is controlled. Otherwise, all players are controlled.
List<Player> players = playerService.getAllPlayers();
String playerId = (String) request.getSession().getAttribute("player");
if (playerId != null) {
Player player = playerService.getPlayerById(playerId);
if (player != null) {
players = Arrays.asList(player);
}
}
Map<String, Object> map = new HashMap<String, Object>();
for (Player player : players) {
PlayQueue playQueue = player.getPlayQueue();
map.put("playlist", playQueue);
if (request.getParameter("play") != null) {
MediaFile file = mediaFileService.getMediaFile(request.getParameter("play"));
playQueue.addFiles(false, file);
} else if (request.getParameter("add") != null) {
MediaFile file = mediaFileService.getMediaFile(request.getParameter("add"));
playQueue.addFiles(true, file);
} else if (request.getParameter("skip") != null) {
playQueue.setIndex(Integer.parseInt(request.getParameter("skip")));
} else if (request.getParameter("clear") != null) {
playQueue.clear();
} else if (request.getParameter("load") != null) {
List<MediaFile> songs = playlistService.getFilesInPlaylist(ServletRequestUtils.getIntParameter(request, "id"));
playQueue.addFiles(false, songs);
} else if (request.getParameter("random") != null) {
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(securityService.getCurrentUsername(request));
List<MediaFile> randomFiles = searchService.getRandomSongs(new RandomSearchCriteria(20, null, null, null, musicFolders));
playQueue.addFiles(false, randomFiles);
}
}
map.put("players", players);
return new ModelAndView("wap/playlist", "model", map);
}
public ModelAndView loadPlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("playlists", playlistService.getReadablePlaylistsForUser(securityService.getCurrentUsername(request)));
return new ModelAndView("wap/loadPlaylist", "model", map);
}
public ModelAndView search(HttpServletRequest request, HttpServletResponse response) throws Exception {
return new ModelAndView("wap/search");
}
public ModelAndView searchResult(HttpServletRequest request, HttpServletResponse response) throws Exception {
String username = securityService.getCurrentUsername(request);
String query = request.getParameter("query");
Map<String, Object> map = new HashMap<String, Object>();
map.put("hits", search(query, username));
return new ModelAndView("wap/searchResult", "model", map);
}
public ModelAndView settings(HttpServletRequest request, HttpServletResponse response) throws Exception {
String playerId = (String) request.getSession().getAttribute("player");
List<Player> allPlayers = playerService.getAllPlayers();
User user = securityService.getCurrentUser(request);
List<Player> players = new ArrayList<Player>();
Map<String, Object> map = new HashMap<String, Object>();
for (Player player : allPlayers) {
// Only display authorized players.
if (user.isAdminRole() || user.getUsername().equals(player.getUsername())) {
players.add(player);
}
}
map.put("playerId", playerId);
map.put("players", players);
return new ModelAndView("wap/settings", "model", map);
}
public ModelAndView selectPlayer(HttpServletRequest request, HttpServletResponse response) throws Exception {
request.getSession().setAttribute("player", request.getParameter("playerId"));
return settings(request, response);
}
private List<MediaFile> search(String query, String username) throws IOException {
SearchCriteria criteria = new SearchCriteria();
criteria.setQuery(query);
criteria.setOffset(0);
criteria.setCount(50);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
SearchResult result = searchService.search(criteria, musicFolders, SearchService.IndexType.SONG);
return result.getMediaFiles();
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setMusicIndexService(MusicIndexService musicIndexService) {
this.musicIndexService = musicIndexService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
}

@ -0,0 +1,38 @@
package org.libresonic.player.security;
import org.springframework.security.web.util.matcher.RegexRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.regex.Pattern;
/**
* See
*
* http://blogs.sourceallies.com/2014/04/customizing-csrf-protection-in-spring-security/
* https://docs.spring.io/spring-security/site/docs/current/reference/html/appendix-namespace.html#nsa-csrf
*
*
*/
@Component
public class CsrfSecurityRequestMatcher implements RequestMatcher {
private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");
private RegexRequestMatcher dwrRequestMatcher = new RegexRequestMatcher("/dwr/.*\\.dwr", "POST");
@Override
public boolean matches(HttpServletRequest request) {
boolean requireCsrfToken = true;
if(allowedMethods.matcher(request.getMethod()).matches()){
requireCsrfToken = false;
} else {
if (dwrRequestMatcher.matches(request)) {
requireCsrfToken = false;
}
}
return requireCsrfToken;
}
}

@ -20,6 +20,7 @@
package org.libresonic.player.security;
import org.libresonic.player.Logger;
import org.springframework.stereotype.Component;
/**
* Logs login failures. Can be used by tools like fail2ban for blocking IP addresses.
@ -27,6 +28,7 @@ import org.libresonic.player.Logger;
* @author Sindre Mehus
* @version $Id$
*/
@Component
public class LoginFailureLogger {
private static final Logger LOG = Logger.getLogger(LoginFailureLogger.class);

@ -27,13 +27,14 @@ import org.libresonic.player.controller.RESTController;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.Version;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.util.matcher.RegexRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
@ -56,11 +57,17 @@ public class RESTRequestParameterProcessingFilter implements Filter {
private static final Logger LOG = Logger.getLogger(RESTRequestParameterProcessingFilter.class);
private final JAXBWriter jaxbWriter = new JAXBWriter();
private ProviderManager authenticationManager;
private SettingsService settingsService;
private AuthenticationManager authenticationManager;
private SecurityService securityService;
private LoginFailureLogger loginFailureLogger;
private static RequestMatcher requiresAuthenticationRequestMatcher = new RegexRequestMatcher("/rest/.+\\.view\\??.*",null);
protected boolean requiresAuthentication(HttpServletRequest request,
HttpServletResponse response) {
return requiresAuthenticationRequestMatcher.matches(request);
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (!(request instanceof HttpServletRequest)) {
throw new ServletException("Can only process HttpServletRequest");
@ -72,6 +79,13 @@ public class RESTRequestParameterProcessingFilter implements Filter {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
if (!requiresAuthentication(httpRequest, httpResponse)) {
chain.doFilter(request, response);
return;
}
String username = StringUtils.trimToNull(httpRequest.getParameter("u"));
String password = decrypt(StringUtils.trimToNull(httpRequest.getParameter("p")));
String salt = StringUtils.trimToNull(httpRequest.getParameter("s"));
@ -185,18 +199,20 @@ public class RESTRequestParameterProcessingFilter implements Filter {
public void destroy() {
}
public void setAuthenticationManager(ProviderManager authenticationManager) {
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
public SecurityService getSecurityService() {
return securityService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setLoginFailureLogger(LoginFailureLogger loginFailureLogger) {
this.loginFailureLogger = loginFailureLogger;
}

@ -0,0 +1,92 @@
package org.libresonic.player.security;
import org.libresonic.player.service.SecurityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityService securityService;
@Autowired
private CsrfSecurityRequestMatcher csrfSecurityRequestMatcher;
@Autowired
LoginFailureLogger loginFailureLogger;
@Override
@Bean(name = "authenticationManager")
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(securityService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
RESTRequestParameterProcessingFilter restAuthenticationFilter = new RESTRequestParameterProcessingFilter();
restAuthenticationFilter.setAuthenticationManager((AuthenticationManager) getApplicationContext().getBean("authenticationManager"));
restAuthenticationFilter.setSecurityService(securityService);
restAuthenticationFilter.setLoginFailureLogger(loginFailureLogger);
http = http.addFilterBefore(restAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
http
.csrf()
.requireCsrfProtectionMatcher(csrfSecurityRequestMatcher)
.and().headers()
.frameOptions()
.sameOrigin()
.and().authorizeRequests()
.antMatchers("recover.view", "accessDenied.view",
"coverArt.view", "/hls/**", "/stream/**", "/ws/**",
"/share/**", "/style/**", "/icons/**",
"/flash/**", "/script/**", "/sonos/**", "/crossdomain.xml")
.permitAll()
.antMatchers("/personalSettings.view", "/passwordSettings.view",
"/playerSettings.view", "/shareSettings.view")
.hasRole("SETTINGS")
.antMatchers("/generalSettings.view","/advancedSettings.view","/userSettings.view",
"/musicFolderSettings.view","/networkSettings.view")
.hasRole("ADMIN")
.antMatchers("/deletePlaylist.view","/savePlaylist.view")
.hasRole("PLAYLIST")
.antMatchers("/download.view")
.hasRole("DOWNLOAD")
.antMatchers("/upload.view")
.hasRole("UPLOAD")
.antMatchers("/createShare.view")
.hasRole("SHARE")
.antMatchers("/changeCoverArt.view","/editTags.view")
.hasRole("COVERART")
.antMatchers("/setMusicFileInfo.view")
.hasRole("COMMENT")
.antMatchers("/podcastReceiverAdmin.view")
.hasRole("PODCAST")
.antMatchers("/**")
.hasRole("USER")
.anyRequest().authenticated()
.and().formLogin()
.loginPage("/login")
.permitAll()
.defaultSuccessUrl("/index.view")
.failureUrl("/login?error=1")
.usernameParameter("j_username")
.passwordParameter("j_password")
.and().rememberMe().userDetailsService(securityService).key("libresonic");
}
}

@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
profile="embed">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">

@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
profile="legacy">
<bean id="dataSource"

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="org.libresonic.player.controller,
org.libresonic.player.validator,
org.libresonic.player.security"/>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
<prop key="/podcast/**">podcastController</prop>
</props>
</property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="org.libresonic.player.i18n.ResourceBundle"/>
</bean>
<bean id="themeSource" class="org.libresonic.player.theme.LibresonicThemeSource">
<property name="basenamePrefix" value="org.libresonic.player.theme."/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="themeResolver" class="org.libresonic.player.theme.LibresonicThemeResolver">
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<security:http auto-config='true'>
<!-- IS_AUTHENTICATED_ANONYMOUSLY -->
<security:intercept-url pattern="/login.*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<security:intercept-url pattern="/recover.view" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/accessDenied.view" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/coverArt.view" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/hls/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/stream/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/ws/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/share/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/style/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/icons/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/flash/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/script/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/sonos/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/crossdomain.xml" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<!-- ROLE_SETTINGS -->
<security:intercept-url pattern="/personalSettings.view" access="ROLE_SETTINGS" />
<security:intercept-url pattern="/passwordSettings.view" access="ROLE_SETTINGS" />
<security:intercept-url pattern="/playerSettings.view" access="ROLE_SETTINGS" />
<security:intercept-url pattern="/shareSettings.view" access="ROLE_SETTINGS" />
<!-- ROLE_ADMIN -->
<security:intercept-url pattern="/generalSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/advancedSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/userSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/musicFolderSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/networkSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/dlnaSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/sonosSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/transcodingSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/internetRadioSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/podcastSettings.view" access="ROLE_ADMIN" />
<security:intercept-url pattern="/db.view" access="ROLE_ADMIN" />
<!-- MISC -->
<security:intercept-url pattern="/deletePlaylist.view" access="ROLE_PLAYLIST" />
<security:intercept-url pattern="/savePlaylist.view" access="ROLE_PLAYLIST" />
<security:intercept-url pattern="/download.view" access="ROLE_DOWNLOAD" />
<security:intercept-url pattern="/upload.view" access="ROLE_UPLOAD" />
<security:intercept-url pattern="/createShare.view" access="ROLE_SHARE" />
<security:intercept-url pattern="/changeCoverArt.view" access="ROLE_COVERART" />
<security:intercept-url pattern="/editTags.view" access="ROLE_COVERART" />
<security:intercept-url pattern="/setMusicFileInfo.view" access="ROLE_COMMENT" />
<security:intercept-url pattern="/podcastReceiverAdmin.view" access="ROLE_PODCAST" />
<!-- ROLE_USER -->
<security:intercept-url pattern="/**" access="ROLE_USER" />
<security:form-login login-page="/login.view"
default-target-url="/index.view"
authentication-failure-url="/login.view?error=1"
always-use-default-target="true"/>
<security:remember-me user-service-ref="securityService" key="libresonic"/>
</security:http>
<security:authentication-manager>
<security:authentication-provider user-service-ref="securityService" />
</security:authentication-manager>
</beans>

@ -4,5 +4,6 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="sub" uri="http://libresonic.org/taglib/sub" %>
<%@ taglib prefix="str" uri="http://jakarta.apache.org/taglibs/string-1.1" %>

@ -12,7 +12,9 @@
</head>
<body class="mainframe bgcolor1" onload="document.getElementById('j_username').focus()">
<form action="<c:url value="/j_spring_security_check"/>" method="POST">
<form action="/login" method="POST">
<sec:csrfInput />
<div class="bgcolor2 shadow" align="center" style="padding:20px 50px 20px 50px; margin-top:100px;margin-left:50px;margin-right:50px">
<div style="margin-bottom:1em;max-width:50em;text-align:left;"><sub:wiki text="${model.loginMessage}"/></div>

@ -99,7 +99,7 @@
</tr></table>
<c:if test="${model.user.podcastRole}">
<form method="post" action="podcastReceiverAdmin.view?">
<form:form method="post" action="podcastReceiverAdmin.view?">
<table>
<tr>
<td><fmt:message key="podcastreceiver.subscribe"/></td>
@ -107,7 +107,7 @@
<td><input type="submit" value="<fmt:message key="common.ok"/>"/></td>
</tr>
</table>
</form>
</form:form>
</c:if>
</body>

@ -64,7 +64,7 @@
<script type="text/javascript">
var CastPlayer = new CastPlayer();
</script>
</c:if>
<h1 style="padding-top:1em;padding-bottom:0.5em;">
<img id="starImage" src="<spring:theme code="${not empty model.video.starredDate ? 'ratingOnImage' : 'ratingOffImage'}"/>"

@ -1,370 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/>
<bean id="leftController" class="org.libresonic.player.controller.LeftController">
<property name="viewName" value="left"/>
<property name="mediaScannerService" ref="mediaScannerService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="musicIndexService" ref="musicIndexService"/>
<property name="playerService" ref="playerService"/>
</bean>
<bean id="rightController" class="org.libresonic.player.controller.RightController">
<property name="viewName" value="right"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="versionService" ref="versionService"/>
</bean>
<bean id="statusController" class="org.libresonic.player.controller.StatusController">
<property name="viewName" value="status"/>
<property name="statusService" ref="statusService"/>
</bean>
<bean id="mainController" class="org.libresonic.player.controller.MainController">
<property name="securityService" ref="securityService"/>
<property name="playerService" ref="playerService"/>
<property name="settingsService" ref="settingsService"/>
<property name="ratingService" ref="ratingService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="adService" ref="adService"/>
</bean>
<bean id="playlistController" class="org.libresonic.player.controller.PlaylistController">
<property name="viewName" value="playlist"/>
<property name="securityService" ref="securityService"/>
<property name="playlistService" ref="playlistService"/>
<property name="settingsService" ref="settingsService"/>
<property name="playerService" ref="playerService"/>
</bean>
<bean id="playlistsController" class="org.libresonic.player.controller.PlaylistsController">
<property name="viewName" value="playlists"/>
<property name="securityService" ref="securityService"/>
<property name="playlistService" ref="playlistService"/>
</bean>
<bean id="importPlaylistController" class="org.libresonic.player.controller.ImportPlaylistController">
<property name="viewName" value="importPlaylist"/>
<property name="securityService" ref="securityService"/>
<property name="playlistService" ref="playlistService"/>
</bean>
<bean id="topController" class="org.libresonic.player.controller.TopController">
<property name="viewName" value="top"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="helpController" class="org.libresonic.player.controller.HelpController">
<property name="viewName" value="help"/>
<property name="versionService" ref="versionService"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="moreController" class="org.libresonic.player.controller.MoreController">
<property name="viewName" value="more"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="playerService" ref="playerService"/>
</bean>
<bean id="uploadController" class="org.libresonic.player.controller.UploadController">
<property name="viewName" value="upload"/>
<property name="securityService" ref="securityService"/>
<property name="statusService" ref="statusService"/>
<property name="playerService" ref="playerService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="lyricsController" class="org.libresonic.player.controller.LyricsController">
<property name="viewName" value="lyrics"/>
</bean>
<bean id="allmusicController" class="org.libresonic.player.controller.AllmusicController">
<property name="viewName" value="allmusic"/>
</bean>
<bean id="podcastController" class="org.libresonic.player.controller.PodcastController">
<property name="viewName" value="podcast"/>
<property name="playlistService" ref="playlistService"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="podcastChannelsController" class="org.libresonic.player.controller.PodcastChannelsController">
<property name="viewName" value="podcastChannels"/>
<property name="podcastService" ref="podcastService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="podcastChannelController" class="org.libresonic.player.controller.PodcastChannelController">
<property name="viewName" value="podcastChannel"/>
<property name="podcastService" ref="podcastService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="podcastReceiverAdminController" class="org.libresonic.player.controller.PodcastReceiverAdminController">
<property name="podcastService" ref="podcastService"/>
</bean>
<bean id="setMusicFileInfoController" class="org.libresonic.player.controller.SetMusicFileInfoController">
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="shareManagementController" class="org.libresonic.player.controller.ShareManagementController">
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="shareService" ref="shareService"/>
<property name="playerService" ref="playerService"/>
<property name="playlistService" ref="playlistService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="setRatingController" class="org.libresonic.player.controller.SetRatingController">
<property name="ratingService" ref="ratingService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="changeCoverArtController" class="org.libresonic.player.controller.ChangeCoverArtController">
<property name="viewName" value="changeCoverArt"/>
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="nowPlayingController" class="org.libresonic.player.controller.NowPlayingController">
<property name="playerService" ref="playerService"/>
<property name="statusService" ref="statusService"/>
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="starredController" class="org.libresonic.player.controller.StarredController">
<property name="viewName" value="starred"/>
<property name="playerService" ref="playerService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileDao" ref="mediaFileDao"/>
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="settingsController" class="org.libresonic.player.controller.SettingsController">
<property name="securityService" ref="securityService"/>
</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="homeController" class="org.libresonic.player.controller.HomeController">
<property name="viewName" value="home"/>
<property name="ratingService" ref="ratingService"/>
<property name="mediaScannerService" ref="mediaScannerService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="searchService" ref="searchService"/>
<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="playQueueController" class="org.libresonic.player.controller.PlayQueueController">
<property name="viewName" value="playQueue"/>
<property name="playerService" ref="playerService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="coverArtController" class="org.libresonic.player.controller.CoverArtController" init-method="init">
<property name="mediaFileService" ref="mediaFileService"/>
<property name="transcodingService" ref="transcodingService"/>
<property name="settingsService" ref="settingsService"/>
<property name="playlistService" ref="playlistService"/>
<property name="podcastService" ref="podcastService"/>
<property name="artistDao" ref="artistDao"/>
<property name="albumDao" ref="albumDao"/>
</bean>
<bean id="avatarController" class="org.libresonic.player.controller.AvatarController">
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="proxyController" class="org.libresonic.player.controller.ProxyController"/>
<bean id="statusChartController" class="org.libresonic.player.controller.StatusChartController">
<property name="statusService" ref="statusService"/>
</bean>
<bean id="userChartController" class="org.libresonic.player.controller.UserChartController">
<property name="securityService" ref="securityService"/>
</bean>
<bean id="m3uController" class="org.libresonic.player.controller.M3UController">
<property name="playerService" ref="playerService"/>
<property name="settingsService" ref="settingsService"/>
<property name="transcodingService" ref="transcodingService"/>
</bean>
<bean id="streamController" class="org.libresonic.player.controller.StreamController">
<property name="playerService" ref="playerService"/>
<property name="playlistService" ref="playlistService"/>
<property name="statusService" ref="statusService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="searchService" ref="searchService"/>
<property name="transcodingService" ref="transcodingService"/>
<property name="audioScrobblerService" ref="audioScrobblerService"/>
</bean>
<bean id="hlsController" class="org.libresonic.player.controller.HLSController">
<property name="playerService" ref="playerService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="videoPlayerController" class="org.libresonic.player.controller.VideoPlayerController">
<property name="viewName" value="videoPlayer"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="settingsService" ref="settingsService"/>
<property name="playerService" ref="playerService"/>
<property name="securityService" ref="securityService"/>
</bean>
<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="downloadController" class="org.libresonic.player.controller.DownloadController">
<property name="playerService" ref="playerService"/>
<property name="statusService" ref="statusService"/>
<property name="securityService" ref="securityService"/>
<property name="playlistService" ref="playlistService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="multiController" class="org.libresonic.player.controller.MultiController">
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="playlistService" ref="playlistService"/>
</bean>
<bean id="wapController" class="org.libresonic.player.controller.WapController">
<property name="settingsService" ref="settingsService"/>
<property name="playerService" ref="playerService"/>
<property name="playlistService" ref="playlistService"/>
<property name="searchService" ref="searchService"/>
<property name="securityService" ref="securityService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="musicIndexService" ref="musicIndexService"/>
</bean>
<bean id="restController" class="org.libresonic.player.controller.RESTController" init-method="init">
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
<property name="playerService" ref="playerService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="lastFmService" ref="lastFmService"/>
<property name="musicIndexService" ref="musicIndexService"/>
<property name="transcodingService" ref="transcodingService"/>
<property name="statusService" ref="statusService"/>
<property name="searchService" ref="searchService"/>
<property name="jukeboxService" ref="jukeboxService"/>
<property name="audioScrobblerService" ref="audioScrobblerService"/>
<property name="playlistService" ref="playlistService"/>
<property name="playQueueService" ref="ajaxPlayQueueService"/>
<property name="ratingService" ref="ratingService"/>
<property name="chatService" ref="ajaxChatService"/>
<property name="lyricsService" ref="ajaxLyricsService"/>
<property name="podcastService" ref="podcastService"/>
<property name="shareService" ref="shareService"/>
<property name="mediaFileDao" ref="mediaFileDao"/>
<property name="artistDao" ref="artistDao"/>
<property name="albumDao" ref="albumDao"/>
<property name="bookmarkDao" ref="bookmarkDao"/>
<property name="playQueueDao" ref="playQueueDao"/>
<property name="downloadController" ref="downloadController"/>
<property name="streamController" ref="streamController"/>
<property name="hlsController" ref="hlsController"/>
<property name="coverArtController" ref="coverArtController"/>
<property name="avatarController" ref="avatarController"/>
<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="/main.view">mainController</prop>
<prop key="/playlist.view">playlistController</prop>
<prop key="/playlists.view">playlistsController</prop>
<prop key="/help.view">helpController</prop>
<prop key="/lyrics.view">lyricsController</prop>
<prop key="/left.view">leftController</prop>
<prop key="/right.view">rightController</prop>
<prop key="/status.view">statusController</prop>
<prop key="/more.view">moreController</prop>
<prop key="/upload.view">uploadController</prop>
<prop key="/importPlaylist.view">importPlaylistController</prop>
<prop key="/exportPlaylist.view">multiController</prop>
<prop key="/setMusicFileInfo.view">setMusicFileInfoController</prop>
<prop key="/createShare.view">shareManagementController</prop>
<prop key="/setRating.view">setRatingController</prop>
<prop key="/top.view">topController</prop>
<prop key="/changeCoverArt.view">changeCoverArtController</prop>
<!--
login.view has moved to the LoginController
<prop key="/login.view">multiController</prop>
-->
<prop key="/recover.view">multiController</prop>
<prop key="/accessDenied.view">multiController</prop>
<prop key="/notFound.view">multiController</prop>
<prop key="/gettingStarted.view">multiController</prop>
<prop key="/index.view">multiController</prop>
<prop key="/videoPlayer.view">videoPlayerController</prop>
<prop key="/nowPlaying.view">nowPlayingController</prop>
<prop key="/starred.view">starredController</prop>
<prop key="/settings.view">settingsController</prop>
<prop key="/avatarUpload.view">avatarUploadController</prop>
<prop key="/allmusic.view">allmusicController</prop>
<prop key="/home.view">homeController</prop>
<prop key="/editTags.view">editTagsController</prop>
<prop key="/playQueue.view">playQueueController</prop>
<prop key="/coverArt.view">coverArtController</prop>
<prop key="/avatar.view">avatarController</prop>
<prop key="/proxy.view">proxyController</prop>
<prop key="/statusChart.view">statusChartController</prop>
<prop key="/userChart.view">userChartController</prop>
<prop key="/download.view">downloadController</prop>
<prop key="/db.view">dbController</prop>
<prop key="/test.view">multiController</prop>
<prop key="/podcastChannels.view">podcastChannelsController</prop>
<prop key="/podcastChannel.view">podcastChannelController</prop>
<prop key="/podcastReceiverAdmin.view">podcastReceiverAdminController</prop>
<prop key="/podcast.view">podcastController</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="/play.m3u">m3uController</prop>
<prop key="/stream/**">streamController</prop>
<prop key="/hls/**">hlsController</prop>
<prop key="/share/**">externalPlayerController</prop>
</props>
</property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="org.libresonic.player.i18n.ResourceBundle"/>
</bean>
<bean id="themeSource" class="org.libresonic.player.theme.LibresonicThemeSource">
<property name="basenamePrefix" value="org.libresonic.player.theme."/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="themeResolver" class="org.libresonic.player.theme.LibresonicThemeResolver">
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.libresonic.player.spring.LoggingExceptionResolver" />
</beans>

File diff suppressed because one or more lines are too long

@ -8,7 +8,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<build>

@ -8,7 +8,7 @@
<parent>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
</parent>
<build>

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.libresonic.player</groupId>
<artifactId>libresonic</artifactId>
<version>6.2.beta1.spring4</version>
<version>6.2.beta1.springboot</version>
<name>Libresonic</name>
<packaging>pom</packaging>
<organization>
@ -17,8 +17,6 @@
<failOnDependencyWarning>true</failOnDependencyWarning>
<project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding>
<cxf.version>3.1.8</cxf.version>
<spring.version>4.3.4.RELEASE</spring.version>
<spring.security.version>3.2.9.RELEASE</spring.security.version>
</properties>
<repositories>
@ -96,60 +94,12 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
@ -213,6 +163,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>analyze</id>
@ -222,14 +173,20 @@
<configuration>
<failOnWarning>${failOnDependencyWarning}</failOnWarning>
<ignoreNonCompile>true</ignoreNonCompile>
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>org.springframework:*</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>org.springframework.security:*</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>org.springframework.boot:*</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>org.apache.tomcat.embed:tomcat-embed-core*</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>com.sun.mail:javax.mail*</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.seamless:seamless-http*</ignoredUnusedDeclaredDependency>
<!-- Needed for libresonic-booter to load Libresonic correctly -->
<ignoredUnusedDeclaredDependency>org.springframework.security:spring-security-config*</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>com.sun.mail:javax.mail*</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.seamless:seamless-http*</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>taglibs:string:jar*</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.seamless:seamless-http*</ignoredUnusedDeclaredDependency>
<!-- Needed for libresonic-booter to load Libresonic correctly -->
<ignoredUnusedDeclaredDependency>org.springframework.security:*</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.springframework.boot:spring-boot*</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>

Loading…
Cancel
Save