forgot non-zipped master files
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
logging.level.com.bayer=DEBUG
|
logging.level.com.bayer=DEBUG
|
||||||
#logging.level.com.bayer.edam.migration.interceptors=INFO
|
#logging.level.com.bayer.edam.migration.interceptors=INFO
|
||||||
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
|
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
|
||||||
logging.file=application-WED.log
|
logging.file=application-THU.log
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(MamMigrationSelective.class);
|
private static final Logger log = LoggerFactory.getLogger(MamMigrationSelective.class);
|
||||||
|
|
||||||
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
|
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
|
||||||
private List<Integer> entrySelection = new ArrayList<Integer>(Arrays.asList( 71725, 71263, 71048, 70778, 70746, 70745, 70440, 70361, 70340, 70288, 70161, 70142, 63924, 63201, 57641, 56942 ));
|
private List<Integer> entrySelection = new ArrayList<Integer>(Arrays.asList( 71725 /*, 71263, 71048, 70778, 70746, 70745, 70440, 70361, 70340, 70288, 70161, 70142, 63924, 63201, 57641, 56942 */));
|
||||||
|
|
||||||
static final String fileCache = "E:\\";
|
static final String fileCache = "E:\\";
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
@Value("${adam.auth}")
|
@Value("${adam.auth}")
|
||||||
private String adamAuth;
|
private String adamAuth;
|
||||||
|
|
||||||
RestTemplate restTemplate;
|
RestTemplate restTemplate, fileTransferTemplate;
|
||||||
HttpHeaders adamHeaders, adamUploadHeaders, mamHeaders;
|
HttpHeaders adamHeaders, adamUploadHeaders, mamHeaders;
|
||||||
HttpEntity<String> adamHeadersEntity;
|
HttpEntity<String> adamHeadersEntity;
|
||||||
|
|
||||||
@@ -104,6 +104,11 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
log.info("Read categories");
|
log.info("Read categories");
|
||||||
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
mamCategoryTree = new CategoryTree(categoryJson, categoryMapping);
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||||
|
requestFactory.setBufferRequestBody(false);
|
||||||
|
fileTransferTemplate = new RestTemplate(requestFactory);
|
||||||
|
|
||||||
restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
|
restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
|
||||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
|
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
|
||||||
interceptors.add(new LoggingRequestInterceptor());
|
interceptors.add(new LoggingRequestInterceptor());
|
||||||
@@ -255,7 +260,14 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
|
|
||||||
// Brands "General" and "Others" are weaker than the other brands
|
// Brands "General" and "Others" are weaker than the other brands
|
||||||
if (p.startsWith("Brand.")) {
|
if (p.startsWith("Brand.")) {
|
||||||
if ((p.equals("Brand.General") || p.equals("Brand.CAP.Others") || p.equals("Brand.FAP.Others"))&& record.hasClassificationStartingWith("Brand.")) {
|
if ((p.equals("Brand.General") || p.equals("Brand.CAP.Others") || p.equals("Brand.FAP.Others"))
|
||||||
|
&& record.hasClassificationStartingWith("Brand.")) {
|
||||||
|
|
||||||
|
// Check if the brand matches the business unit XXX
|
||||||
|
// if ((p.equals("Brand.General") && record.hasClassificationStartingWith("BusinessUnit.General")) ||
|
||||||
|
// (p.equals("Brand.CAP.Others") && record.hasClassificationStartingWith("BusinessUnit.CAP")) ||
|
||||||
|
// (p.equals("Brand.FAP.Others") && record.hasClassificationStartingWith("BusinessUnit.FAP")))
|
||||||
|
|
||||||
log.warn("Classification " + p + " not added, different brand already set");
|
log.warn("Classification " + p + " not added, different brand already set");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -510,10 +522,10 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
|
|
||||||
if (selectedDownload != null) {
|
if (selectedDownload != null) {
|
||||||
|
|
||||||
|
File masterFile = getFileForEntry(selectedDownload, entry.id);
|
||||||
|
|
||||||
// if selected download is a zip that contains a single file, upload extracted file as master
|
// if selected download is a zip that contains a single file, upload extracted file as master
|
||||||
if (selectedDownload.fileName.toLowerCase().endsWith(".zip")) {
|
if (selectedDownload.fileName.toLowerCase().endsWith(".zip")) {
|
||||||
File masterFile = getFileForEntry(selectedDownload, entry.id);
|
|
||||||
|
|
||||||
ZipFile zipFile = new ZipFile(masterFile);
|
ZipFile zipFile = new ZipFile(masterFile);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<FileHeader> fileHeaders = zipFile.getFileHeaders();
|
List<FileHeader> fileHeaders = zipFile.getFileHeaders();
|
||||||
@@ -528,10 +540,12 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
log.info("Using extracted master file " + extractedMasterFilePath);
|
log.info("Using extracted master file " + extractedMasterFilePath);
|
||||||
masterFile = new File(extractedMasterFilePath);
|
masterFile = new File(extractedMasterFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
filesForUpload.add(masterFile);
|
|
||||||
hrefsForUpload.add(selectedDownload.href);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX E:\71725 wieder herstellen
|
||||||
|
|
||||||
|
filesForUpload.add(masterFile);
|
||||||
|
hrefsForUpload.add(selectedDownload.href);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn("Could not identify master file for entry " + entry.id);
|
log.warn("Could not identify master file for entry " + entry.id);
|
||||||
@@ -553,7 +567,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
|
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
|
||||||
parameters.add("file", new FileSystemResource(file));
|
parameters.add("file", new FileSystemResource(file));
|
||||||
|
|
||||||
UploadResult result = restTemplate.exchange(Definitions.adamHost + "/uploads", HttpMethod.POST,
|
UploadResult result = fileTransferTemplate.exchange(Definitions.adamHost + "/uploads", HttpMethod.POST,
|
||||||
new HttpEntity<MultiValueMap<String, Object>>(parameters, adamUploadHeaders), UploadResult.class).getBody();
|
new HttpEntity<MultiValueMap<String, Object>>(parameters, adamUploadHeaders), UploadResult.class).getBody();
|
||||||
|
|
||||||
if (result.token != null) {
|
if (result.token != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user