diff --git a/shanoir-ng-import/src/main/java/org/shanoir/ng/importer/ImporterApiController.java b/shanoir-ng-import/src/main/java/org/shanoir/ng/importer/ImporterApiController.java index 01585a3d2f..ca0c23c297 100644 --- a/shanoir-ng-import/src/main/java/org/shanoir/ng/importer/ImporterApiController.java +++ b/shanoir-ng-import/src/main/java/org/shanoir/ng/importer/ImporterApiController.java @@ -75,8 +75,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ByteArrayResource; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; @@ -87,7 +85,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import com.fasterxml.jackson.databind.ObjectMapper; @@ -145,9 +142,6 @@ public class ImporterApiController implements ImporterApi { @Value("${shanoir.import.directory}") private String importDir; - @Autowired - private RestTemplate restTemplate; - @Autowired private DicomDirGeneratorService dicomDirGeneratorService; @@ -279,6 +273,15 @@ public ResponseEntity startImportJob( } } + /** + * cleanSeries is important here for import-from-zip file: when the ImagesCreatorAndDicomFileAnalyzer + * has declared some series as e.g. erroneous, we have to remove them from the import. For import-from + * pacs or from-sh-up it is different, as the ImagesCreatorAndDicomFileAnalyzer is called afterwards. + * Same here for multi-exam-imports: it calls uploadDicomZipFile method, where series could be classed + * as erroneous and when startImportJob is called, we want them to be removed from the import. + * + * @param importJob + */ private void cleanSeries(final ImportJob importJob) { for (Iterator patientIt = importJob.getPatients().iterator(); patientIt.hasNext();) { Patient patient = patientIt.next(); @@ -309,7 +312,6 @@ public ResponseEntity queryPACS( importJob.setWorkFolder(""); importJob.setFromPacs(true); importJob.setUserId(KeycloakUtil.getTokenUserId()); - } catch (ShanoirException e) { throw new RestServiceException( new ErrorModel(HttpStatus.UNPROCESSABLE_ENTITY.value(), e.getMessage(), null)); @@ -332,12 +334,11 @@ public ResponseEntity importDicomZipFile( MockMultipartFile multiPartFile; try { multiPartFile = new MockMultipartFile(tempFile.getName(), tempFile.getName(), APPLICATION_ZIP, new FileInputStream(tempFile.getAbsolutePath())); - // Import dicomfile return uploadDicomZipFile(multiPartFile); } catch (IOException e) { LOG.error("ERROR while loading zip fiole, please contact an administrator"); - e.printStackTrace(); + LOG.error(e.getMessage(), e); return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } finally { // Delete temp file which is useless now @@ -374,12 +375,9 @@ public ResponseEntity uploadEEGZipFile( if (!userImportDir.exists()) { userImportDir.mkdirs(); // create if not yet existing } - // Unzip the file and get the elements File tempFile = ImportUtils.saveTempFile(userImportDir, eegFile); - File importJobDir = ImportUtils.saveTempFileCreateFolderAndUnzip(tempFile, eegFile, false); - EegImportJob importJob = new EegImportJob(); importJob.setUserId(userId); importJob.setArchive(eegFile.getOriginalFilename());