diff --git a/AH MAM Migration/src/com/bayer/edam/migration/EntryDownloader.java b/AH MAM Migration/src/com/bayer/edam/migration/EntryDownloader.java index 9f90254..ce8858e 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/EntryDownloader.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/EntryDownloader.java @@ -2,12 +2,12 @@ package com.bayer.edam.migration; import java.io.File; import java.io.IOException; -import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -18,6 +18,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import com.bayer.edam.migration.mam.Entry; @@ -114,8 +116,15 @@ public class EntryDownloader implements CommandLineRunner { filenameToUse = download.fileNameOnDisc; else filenameToUse = download.fileName; + + ResponseEntity response = restTemplate.exchange(download.href, HttpMethod.GET, entity, byte[].class); - FileUtils.copyURLToFile(new URL(download.href), new File("E:\\" + entry.id + "\\" + filenameToUse), 4000, 240000); + if (response.getStatusCode() == HttpStatus.OK) { + Files.write(Paths.get("E:\\" + entry.id + "\\" + filenameToUse), response.getBody()); + } + else { + log.error(entry.id + ", " + response.getStatusCodeValue() + ", " + download.href); + } } } catch (IOException ioe) {