Loading src/main/java/it/inaf/ia2/transfer/controller/PutFileController.java +22 −15 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.Optional; import javax.servlet.http.HttpServletRequest; import javax.xml.bind.DatatypeConverter; import net.ivoa.xml.uws.v1.ExecutionPhase; import org.slf4j.Logger; Loading Loading @@ -44,8 +45,9 @@ public class PutFileController extends FileController { @PutMapping("/**") public ResponseEntity<?> putFile(@RequestHeader(value = HttpHeaders.CONTENT_ENCODING, required = false) String contentEncoding, @RequestParam("file") MultipartFile file, @RequestParam(value = "jobid", required = false) String jobId) throws IOException, NoSuchAlgorithmException { @RequestParam(value = "file", required = false) MultipartFile file, @RequestParam(value = "jobid", required = false) String jobId, HttpServletRequest request) throws IOException, NoSuchAlgorithmException { String path = getPath(); Loading @@ -54,8 +56,7 @@ public class PutFileController extends FileController { } else { LOG.debug("putFile called for path {} with jobId {}", path, jobId); if(!jobDAO.isJobExisting(jobId)) { if (!jobDAO.isJobExisting(jobId)) { return new ResponseEntity<>("Job " + jobId + " not found", NOT_FOUND); } } Loading @@ -63,17 +64,18 @@ public class PutFileController extends FileController { Optional<FileInfo> optFileInfo = fileDAO.getFileInfo(path); if (optFileInfo.isPresent()) { try (InputStream in = file.getInputStream()) { try (InputStream in = file != null ? file.getInputStream() : request.getInputStream()) { FileInfo fileInfo = optFileInfo.get(); if (fileInfo.getAcceptViews() != null && fileInfo.getAcceptViews().contains("urn:list-of-files")) { storeListOfFiles(fileInfo, in); } else { if (file != null) { fileInfo.setContentType(file.getContentType()); } fileInfo.setContentEncoding(contentEncoding); storeGenericFile(fileInfo, in, jobId); } } return ResponseEntity.ok().build(); } else { Loading Loading @@ -124,6 +126,11 @@ public class PutFileController extends FileController { fileDAO.setBusy(fileInfo.getNodeId(), true); } Files.copy(is, file.toPath()); if (fileInfo.getContentType() == null) { fileInfo.setContentType(Files.probeContentType(file.toPath())); } Long fileSize = Files.size(file.toPath()); String md5Checksum = makeMD5Checksum(file); Loading Loading
src/main/java/it/inaf/ia2/transfer/controller/PutFileController.java +22 −15 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.Optional; import javax.servlet.http.HttpServletRequest; import javax.xml.bind.DatatypeConverter; import net.ivoa.xml.uws.v1.ExecutionPhase; import org.slf4j.Logger; Loading Loading @@ -44,8 +45,9 @@ public class PutFileController extends FileController { @PutMapping("/**") public ResponseEntity<?> putFile(@RequestHeader(value = HttpHeaders.CONTENT_ENCODING, required = false) String contentEncoding, @RequestParam("file") MultipartFile file, @RequestParam(value = "jobid", required = false) String jobId) throws IOException, NoSuchAlgorithmException { @RequestParam(value = "file", required = false) MultipartFile file, @RequestParam(value = "jobid", required = false) String jobId, HttpServletRequest request) throws IOException, NoSuchAlgorithmException { String path = getPath(); Loading @@ -54,8 +56,7 @@ public class PutFileController extends FileController { } else { LOG.debug("putFile called for path {} with jobId {}", path, jobId); if(!jobDAO.isJobExisting(jobId)) { if (!jobDAO.isJobExisting(jobId)) { return new ResponseEntity<>("Job " + jobId + " not found", NOT_FOUND); } } Loading @@ -63,17 +64,18 @@ public class PutFileController extends FileController { Optional<FileInfo> optFileInfo = fileDAO.getFileInfo(path); if (optFileInfo.isPresent()) { try (InputStream in = file.getInputStream()) { try (InputStream in = file != null ? file.getInputStream() : request.getInputStream()) { FileInfo fileInfo = optFileInfo.get(); if (fileInfo.getAcceptViews() != null && fileInfo.getAcceptViews().contains("urn:list-of-files")) { storeListOfFiles(fileInfo, in); } else { if (file != null) { fileInfo.setContentType(file.getContentType()); } fileInfo.setContentEncoding(contentEncoding); storeGenericFile(fileInfo, in, jobId); } } return ResponseEntity.ok().build(); } else { Loading Loading @@ -124,6 +126,11 @@ public class PutFileController extends FileController { fileDAO.setBusy(fileInfo.getNodeId(), true); } Files.copy(is, file.toPath()); if (fileInfo.getContentType() == null) { fileInfo.setContentType(Files.probeContentType(file.toPath())); } Long fileSize = Files.size(file.toPath()); String md5Checksum = makeMD5Checksum(file); Loading