parent
b8ade50810
commit
b2dd04e864
@ -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"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue