diff --git a/AH MAM Migration/resources/application.properties b/AH MAM Migration/resources/application.properties index 83c6a46..ad13ff0 100644 --- a/AH MAM Migration/resources/application.properties +++ b/AH MAM Migration/resources/application.properties @@ -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.log +logging.file=application_2017-11-16_QA_2.log diff --git a/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java b/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java index 94758e5..6891b72 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java @@ -49,7 +49,7 @@ public class Definitions { users = new HashMap(); // 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.Logos", new WriteClassification("de96f8db1de44cc6841ba81c00b9db8e", 1)); diff --git a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java index 634bd29..ed5db05 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java @@ -39,6 +39,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.ResourceAccessException; +import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; 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 fileCache = "E:\\"; + // XXX + static final String fileCache = "E:\\_TEST\\"; static final String categoryJson = "resources/2017-10-19_categories.json"; 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; - HttpEntity entity = new HttpEntity("", mamHeaders); +// HttpEntity entity = new HttpEntity("", mamHeaders); for (long id : entrySelection) { // 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 = entryMap.get(id); @@ -641,9 +643,9 @@ public class MamMigrationSelective implements CommandLineRunner { } } - catch (ResourceAccessException rae) { - log.error("Could not upload " + file.getAbsolutePath() + " (" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rae.getMessage()); - rae.printStackTrace(); + catch (RestClientException rce) { + log.error("FILE RESULT Could not upload " + file.getAbsolutePath() + " (" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rce.getMessage()); + rce.printStackTrace(); } } @@ -679,27 +681,33 @@ public class MamMigrationSelective implements CommandLineRunner { ResponseEntity response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class); log.debug("Response: " + response.toString()); } - catch (Exception e) { - log.error("Exception while attaching file to record " + e.getMessage()); - e.printStackTrace(); + catch (RestClientException rce) { + log.error("ATTACH RESULT Exception while attaching file " + reference.cachePath + " (" + reference.isMaster + ") for " + reference.targetRecord + ": " + rce.getMessage()); + rce.printStackTrace(); } + log.debug("ATTACH RESULT Attached " + reference.cachePath + " (" + reference.isMaster + ") to " + reference.targetRecord); processedReferences.add(reference); } else { log.debug("Checking status of " + reference.cachePath + " for " + reference.uri); - 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); - 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); + try { + 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); + 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); + } + } + } + catch (RestClientException rce) { + log.error("Failed to check status of " + reference.cachePath + " for " + reference.uri); } } }