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