This commit is contained in:
gexce
2017-11-16 15:37:35 +01:00
parent bb1a81ad3a
commit 909f34d062
3 changed files with 30 additions and 22 deletions
@@ -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.log logging.file=application_2017-11-16_QA_2.log
@@ -49,7 +49,7 @@ public class Definitions {
users = new HashMap<String, String>(); users = new HashMap<String, String>();
// XXX QA values // XXX QA values
classifications.put("Migration.Test", new WriteClassification("704deb515e024874a4a0a82700a4dc78", 1)); classifications.put("Migration.Test", new WriteClassification("c07e583879a2409a8536a82d00f0ef5c", 1));
classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1)); classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1));
classifications.put("Migration.Logos", new WriteClassification("de96f8db1de44cc6841ba81c00b9db8e", 1)); classifications.put("Migration.Logos", new WriteClassification("de96f8db1de44cc6841ba81c00b9db8e", 1));
@@ -39,6 +39,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.bayer.edam.migration.adam.Campaign; import com.bayer.edam.migration.adam.Campaign;
@@ -69,7 +70,8 @@ public class MamMigrationSelective implements CommandLineRunner {
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com"; static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
static final String fileCache = "E:\\"; // XXX
static final String fileCache = "E:\\_TEST\\";
static final String categoryJson = "resources/2017-10-19_categories.json"; static final String categoryJson = "resources/2017-10-19_categories.json";
static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv"; static final String categoryMapping = "resources/Media_Assistant_Categories_131017_EDITED_without_archive.csv";
@@ -153,7 +155,7 @@ public class MamMigrationSelective implements CommandLineRunner {
} }
int entryCounter = 1; int entryCounter = 1;
HttpEntity<String> entity = new HttpEntity<String>("", mamHeaders); // HttpEntity<String> entity = new HttpEntity<String>("", mamHeaders);
for (long id : entrySelection) { for (long id : entrySelection) {
// XXX // XXX
@@ -163,7 +165,7 @@ public class MamMigrationSelective implements CommandLineRunner {
log.info("GET entry " + id + " (" + entryCounter++ + ")"); log.info("GET entry " + id + " (" + entryCounter++ + "/" + entrySelection.size() + ")");
// Entry entry = restTemplate.exchange(mamHost + "/rest/migration/entry/{id}", HttpMethod.GET, entity, Entry.class, id).getBody(); // Entry entry = restTemplate.exchange(mamHost + "/rest/migration/entry/{id}", HttpMethod.GET, entity, Entry.class, id).getBody();
Entry entry = entryMap.get(id); Entry entry = entryMap.get(id);
@@ -641,9 +643,9 @@ public class MamMigrationSelective implements CommandLineRunner {
} }
} }
catch (ResourceAccessException rae) { catch (RestClientException rce) {
log.error("Could not upload " + file.getAbsolutePath() + " (" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rae.getMessage()); log.error("FILE RESULT Could not upload " + file.getAbsolutePath() + " (" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rce.getMessage());
rae.printStackTrace(); rce.printStackTrace();
} }
} }
@@ -679,27 +681,33 @@ public class MamMigrationSelective implements CommandLineRunner {
ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class); ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class);
log.debug("Response: " + response.toString()); log.debug("Response: " + response.toString());
} }
catch (Exception e) { catch (RestClientException rce) {
log.error("Exception while attaching file to record " + e.getMessage()); log.error("ATTACH RESULT Exception while attaching file " + reference.cachePath + " (" + reference.isMaster + ") for " + reference.targetRecord + ": " + rce.getMessage());
e.printStackTrace(); rce.printStackTrace();
} }
log.debug("ATTACH RESULT Attached " + reference.cachePath + " (" + reference.isMaster + ") to " + reference.targetRecord);
processedReferences.add(reference); processedReferences.add(reference);
} }
else { else {
log.debug("Checking status of " + reference.cachePath + " for " + reference.uri); log.debug("Checking status of " + reference.cachePath + " for " + reference.uri);
UploadResult result = restTemplate.exchange(Definitions.adamHost + reference.uri, HttpMethod.GET, adamHeadersEntity, UploadResult.class).getBody(); try {
log.debug("Result: " + result); UploadResult result = restTemplate.exchange(Definitions.adamHost + reference.uri, HttpMethod.GET, adamHeadersEntity, UploadResult.class).getBody();
log.debug("Result: " + result);
if (result.token != null) {
log.debug("Storing upload token " + result.token); if (result.token != null) {
reference.token = result.token; log.debug("Storing upload token " + result.token);
} reference.token = result.token;
else if (result.status != null) {
if (result.status.equals("Error")) {
log.error("System could not process file " + reference.cachePath + " for " + reference.targetRecord);
processedReferences.add(reference);
} }
else if (result.status != null) {
if (result.status.equals("Error")) {
log.error("System could not process file " + reference.cachePath + " for " + reference.targetRecord);
processedReferences.add(reference);
}
}
}
catch (RestClientException rce) {
log.error("Failed to check status of " + reference.cachePath + " for " + reference.uri);
} }
} }
} }