diff --git a/AH MAM Migration/resources/application.properties b/AH MAM Migration/resources/application.properties index 64755e7..ddadcd2 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_2017-11-09_QA.log +logging.file=application_2017-11-10_QA.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 9cd0d5d..497a82c 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/Definitions.java @@ -48,8 +48,7 @@ public class Definitions { fieldIDs = new HashMap(); users = new HashMap(); - // XXX - classifications.put("Migration.Filetest", new WriteClassification("f1d058987a3043d5b021a819007ff3c0", 1)); + classifications.put("Migration.Test", new WriteClassification("f1d058987a3043d5b021a819007ff3c0", 1)); // QA values classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1)); @@ -203,6 +202,8 @@ public class Definitions { // XXX PROD values +// classifications.put("Migration.Test", new WriteClassification("0c60449fd3ef43a39eeea827007fb0eb", 1)); +// // classifications.put("Migration", new WriteClassification("351a41cfa5114e6ca3cba81f0089dd2c", 1)); // classifications.put("Migration.Logos", new WriteClassification("fc6f04881e0e42eb9bc1a81f008a0d8d", 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 7fcc7ee..096f357 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java @@ -36,6 +36,7 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory; 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.RestTemplate; import com.bayer.edam.migration.adam.Campaign; @@ -140,8 +141,8 @@ public class MamMigrationSelective implements CommandLineRunner { // XXX // if needed start from a certain ID -// if (id > 32348) -// continue; + if (id > 70746) + continue; @@ -190,7 +191,7 @@ public class MamMigrationSelective implements CommandLineRunner { HashSet campaignGuids = new HashSet(); // XXX - record.addClassification("Migration.Filetest"); + record.addClassification("Migration.Test"); // globally applicable classifications record.addClassification("Migration"); @@ -505,6 +506,13 @@ public class MamMigrationSelective implements CommandLineRunner { catch (HttpStatusCodeException hsce) { log.error("RESULT Skipping entry " + entry.id + ": Error while creating record " + hsce.getStatusCode().toString()); log.error(hsce.getResponseBodyAsString()); + log.error(hsce.getRootCause().toString()); + hsce.printStackTrace(); + } + catch (ResourceAccessException rae) { + log.error("RESULT Could not create record for entry " + entry.id + ": " + rae.getMessage()); + log.error(rae.getRootCause().toString()); + rae.printStackTrace(); } } @@ -573,30 +581,38 @@ public class MamMigrationSelective implements CommandLineRunner { MultiValueMap parameters = new LinkedMultiValueMap(); parameters.add("file", new FileSystemResource(file)); - - UploadResult result = fileTransferTemplate.exchange(Definitions.adamHost + "/uploads", HttpMethod.POST, - new HttpEntity>(parameters, adamUploadHeaders), UploadResult.class).getBody(); - if (result.token != null) { - log.debug("Storing upload token " + result.token); - UploadReference reference = new UploadReference(); - reference.targetRecord = recordLocation; - reference.isMaster = isMaster; - reference.token = result.token; - reference.filename = file.getName(); - openUploads.add(reference); + try { + UploadResult result = fileTransferTemplate.exchange(Definitions.adamHost + "/uploads", HttpMethod.POST, + new HttpEntity>(parameters, adamUploadHeaders), UploadResult.class).getBody(); + + if (result.token != null) { + log.debug("Storing upload token " + result.token); + UploadReference reference = new UploadReference(); + reference.targetRecord = recordLocation; + reference.isMaster = isMaster; + reference.token = result.token; + reference.cachePath = file.getAbsolutePath(); + openUploads.add(reference); + } + else if (result.uri != null) { + log.debug("Storing upload reference " + result.uri); + UploadReference reference = new UploadReference(); + reference.targetRecord = recordLocation; + reference.isMaster = isMaster; + reference.uri = result.uri; + reference.cachePath = file.getAbsolutePath(); + openUploads.add(reference); + } + else { + log.error("No token/URI after upload!"); + } + } - else if (result.uri != null) { - log.debug("Storing upload reference " + result.uri); - UploadReference reference = new UploadReference(); - reference.targetRecord = recordLocation; - reference.isMaster = isMaster; - reference.uri = result.uri; - reference.filename = file.getName(); - openUploads.add(reference); - } - else { - log.error("No token/URI after upload!"); + catch (ResourceAccessException rae) { + log.error("Could not upload " + file.getAbsolutePath() + "(" + isMaster + ") for " + recordLocation + " from entry " + entry.id + ": " + rae.getMessage()); + log.error(rae.getRootCause().toString()); + rae.printStackTrace(); } } @@ -625,7 +641,7 @@ public class MamMigrationSelective implements CommandLineRunner { UploadFileRecord fileRecord = new UploadFileRecord(); fileRecord.addFile(reference.token, reference.isMaster); - log.debug("Attach " + reference.filename + " to " + reference.targetRecord); + log.debug("Attach " + reference.cachePath + " to " + reference.targetRecord); HttpEntity httpEntity = new HttpEntity(fileRecord, adamHeaders); try { @@ -640,7 +656,7 @@ public class MamMigrationSelective implements CommandLineRunner { processedReferences.add(reference); } else { - log.debug("Checking status of " + reference.filename + " 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(); log.debug("Result: " + result); @@ -651,7 +667,7 @@ public class MamMigrationSelective implements CommandLineRunner { } else if (result.status != null) { if (result.status.equals("Error")) { - log.error("System could not process file " + reference.filename + " for " + reference.targetRecord); + log.error("System could not process file " + reference.cachePath + " for " + reference.targetRecord); processedReferences.add(reference); } } diff --git a/AH MAM Migration/src/com/bayer/edam/migration/UploadReference.java b/AH MAM Migration/src/com/bayer/edam/migration/UploadReference.java index 1e76ac1..41a4d11 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/UploadReference.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/UploadReference.java @@ -8,7 +8,8 @@ public class UploadReference { String uri; String token; - String filename; +// String filename; boolean isMaster; + String cachePath; }