|
|
|
@ -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); |
|
|
|
@ -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,7 +216,6 @@ 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. |
|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|