Controller migration

master
Rémi Cocula 8 years ago
parent 217caba28f
commit 8c81778f5a
  1. 2
      libresonic-main/src/main/java/org/libresonic/player/controller/AbstractChartController.java
  2. 11
      libresonic-main/src/main/java/org/libresonic/player/controller/StatusChartController.java
  3. 11
      libresonic-main/src/main/java/org/libresonic/player/controller/UserChartController.java
  4. 8
      libresonic-main/src/main/resources/libresonic-servlet.xml

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

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

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

@ -15,12 +15,6 @@
<mvc:annotation-driven /> <mvc:annotation-driven />
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/> <context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/>
<bean id="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"> <bean id="m3uController" class="org.libresonic.player.controller.M3UController">
<property name="playerService" ref="playerService"/> <property name="playerService" ref="playerService"/>
<property name="settingsService" ref="settingsService"/> <property name="settingsService" ref="settingsService"/>
@ -125,8 +119,6 @@
<prop key="/notFound.view">multiController</prop> <prop key="/notFound.view">multiController</prop>
<prop key="/index.view">multiController</prop> <prop key="/index.view">multiController</prop>
<prop key="/videoPlayer.view">videoPlayerController</prop> <prop key="/videoPlayer.view">videoPlayerController</prop>
<prop key="/statusChart.view">statusChartController</prop>
<prop key="/userChart.view">userChartController</prop>
<prop key="/download.view">downloadController</prop> <prop key="/download.view">downloadController</prop>
<prop key="/db.view">dbController</prop> <prop key="/db.view">dbController</prop>
<prop key="/test.view">multiController</prop> <prop key="/test.view">multiController</prop>

Loading…
Cancel
Save