Weekend-Upload

This commit is contained in:
gexce
2017-11-17 18:14:36 +01:00
parent 9037006db1
commit 21c431ae05
3 changed files with 18 additions and 13 deletions
@@ -2,4 +2,4 @@
logging.level.com.bayer=DEBUG
#logging.level.com.bayer.edam.migration.interceptors=INFO
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
logging.file=application_2017-11-17_71537_Logo.log
logging.file=application_2017-11-17_PROD_Weekend.log
@@ -23,6 +23,7 @@ public class Definitions {
// public static final String adamHost = "https://edam-q.bayer.com:2015";
//
// public static final String defaultLanguage = "c2bd4f9bbb954bcb80c31e924c9c26dc"; // /System/Languages/English
// public static final String defaultRecordLanguage = "a2f73eb4030a4e858b4da6dd00d04d1a"; // Record language "English"
// public static final String defaultProjectLead = "21cfce6116484269a351a71300e1fed0"; // AH-Global-Brandmanager
// public static final String defaultLicenseHolder = "4b82f989fae54a309e17a7470073c36b"; // Bayer Animal Health GmbH
// public static final String defaultAdditionalPermittedUse = "e22aa8a5-c0d9-4e3b-8469-a731010bc1fd"; // N/A
@@ -34,6 +35,7 @@ public class Definitions {
public static final String adamHost = "https://edam.bayer.com:2015";
public static final String defaultLanguage = "c2bd4f9bbb954bcb80c31e924c9c26dc"; // /System/Languages/English
public static final String defaultRecordLanguage = "ef5821c697404b21be74a6db0116a378"; // Record language "English"
public static final String defaultProjectLead = "99ca421d2f7a4aea8096a81f00bd177c"; // InterfaceUserAH
public static final String defaultLicenseHolder = "81c13edeb06f44aab672a747007fe56b"; // Bayer Animal Health GmbH
public static final String defaultAdditionalPermittedUse = "30a04c1dbb24486f823ea73e00dbab92"; // N/A
@@ -191,6 +193,7 @@ public class Definitions {
// fieldIDs.put("byr_ah_releaseDate", "7af57306-002a-4fc4-9273-a78300bdb5bb");
// fieldIDs.put("byr_isCampaign", "ed1b60f4069b48339128a77600bfb82a");
// fieldIDs.put("campaignLocalizedValue", "70af5b79ea1c4cf387c5a77600bfb838");
// fieldIDs.put("byr_ah_language", "62ac8277a8404217b837a6dd00d066d9");
//
// // Users
// users.put("32300", "02bee145-2a37-4f49-acba-a74600bda888"); // marion.schmidtmeier@bayer.com
@@ -204,7 +207,7 @@ public class Definitions {
// XXX PROD values
classifications.put("Migration.Test", new WriteClassification("0c60449fd3ef43a39eeea827007fb0eb", 1));
classifications.put("Migration.Test", new WriteClassification("e6d73a4c32a14d339c50a82e011bfc4d", 1));
classifications.put("Migration", new WriteClassification("351a41cfa5114e6ca3cba81f0089dd2c", 1));
classifications.put("Migration.Logos", new WriteClassification("fc6f04881e0e42eb9bc1a81f008a0d8d", 1));
@@ -346,6 +349,7 @@ public class Definitions {
fieldIDs.put("byr_ah_releaseDate", "820c46c1-d98e-436e-8aee-a76800863984");
fieldIDs.put("byr_isCampaign", "59a73a6fe3754f24a3ffa7970078b1c5");
fieldIDs.put("campaignLocalizedValue", "2504158b335b4f488157a7970078b1d3");
fieldIDs.put("byr_ah_language", "366911dd7926442fab92a6db0116fba3");
// Users
users.put("32421", "c57444c4-7149-4ee2-8f5d-a7290078047f"); // claudia.staubes-dunkel@bayer.com
@@ -70,7 +70,7 @@ public class MamMigrationSelective implements CommandLineRunner {
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
// XXX
static final String fileCache = "E:\\_TEST\\";
static final String fileCache = "E:\\";
static final String categoryJson = "resources/2017-10-19_categories.json";
static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv";
@@ -111,13 +111,11 @@ public class MamMigrationSelective implements CommandLineRunner {
// XXX ----------------------------------------------------------------
// Option 1: Process all available entries
// entrySelection = new ArrayList<Long>(entryMap.keySet());
entrySelection = new ArrayList<Long>(entryMap.keySet());
// Option 2: Process a fixed set of entry IDs
// entrySelection = Arrays.asList(71725L, 71263L, 71048L, 70778L, 70746L, 70745L, 70440L, 70361L, 70340L, 70288L, 70161L, 70142L,
// 63924L, 63201L, 57641L, 56942L);
entrySelection = Arrays.asList(71537L);
// entrySelection = Arrays.asList(71725L, 71537L, 71263L, 71048L, 70778L, 70746L, 70745L,
// 70440L, 70361L, 70340L, 70288L, 70161L, 70142L, 63924L, 63201L, 57641L, 56942L);
// Option 3: Read entry IDs from file
// entrySelection = new ArrayList<Long>();
@@ -202,7 +200,7 @@ public class MamMigrationSelective implements CommandLineRunner {
while (openUploads.size() > 0) {
log.debug("Sleeping...");
TimeUnit.SECONDS.sleep(10);
TimeUnit.SECONDS.sleep(120);
log.debug("Checking back on open uploads");
attachOpenUploads();
@@ -439,6 +437,8 @@ public class MamMigrationSelective implements CommandLineRunner {
if (entry.creationDate != null)
record.addField("byr_ah_releaseDate", isoDate.format(entry.creationDate));
record.addField("byr_ah_language", Collections.singletonList(Definitions.defaultRecordLanguage));
if (entry.metaData.get("photographer") != null)
record.addField("byr_ah_photographer", entry.metaData.get("photographer"));
@@ -635,6 +635,7 @@ public class MamMigrationSelective implements CommandLineRunner {
}
}
log.debug("Selected master file " + masterFile.getAbsolutePath() + " for record " + recordLocation);
filesForUpload.add(masterFile);
hrefsForUpload.add(selectedDownload.href);
}
@@ -701,7 +702,7 @@ public class MamMigrationSelective implements CommandLineRunner {
}
else {
// TODO
log.debug("File too large, could not upload " + file.getName() + " for " + recordLocation);
log.error("File too large, could not upload " + file.getName() + " for " + recordLocation);
}
}
else {
@@ -728,8 +729,8 @@ public class MamMigrationSelective implements CommandLineRunner {
HttpEntity<UploadFileRecord> httpEntity = new HttpEntity<UploadFileRecord>(fileRecord, adamHeaders);
try {
ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class);
log.debug("ATTACH RESULT Attached " + reference.cachePath + " (" + reference.isMaster + ") to " + reference.targetRecord);
restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class);
log.debug("ATTACH RESULT Attached " + reference.cachePath + " (" + reference.isMaster + ") to " + reference.targetRecord + " via " + reference.token);
}
catch (RestClientException rce) {
log.error("ATTACH RESULT Exception while attaching file " + reference.cachePath + " (" + reference.isMaster + ") for " + reference.targetRecord + ": " + rce.getMessage());
@@ -739,7 +740,7 @@ public class MamMigrationSelective implements CommandLineRunner {
processedReferences.add(reference);
}
else {
log.debug("Checking status of " + reference.cachePath + " for " + reference.uri);
log.debug("Checking status of " + reference.cachePath + " for " + reference.targetRecord + " at " + reference.uri);
try {
UploadResult result = restTemplate.exchange(Definitions.adamHost + reference.uri, HttpMethod.GET, adamHeadersEntity, UploadResult.class).getBody();
log.debug("Result: " + result);