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 f48ba91..ca595e6 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java @@ -167,7 +167,7 @@ public class MamMigrationSelective implements CommandLineRunner { while (openUploads.size() > 0) { log.debug("Sleeping..."); - TimeUnit.SECONDS.sleep(10); // XXX + TimeUnit.SECONDS.sleep(5); // XXX log.debug("Checking back on open uploads"); attachOpenUploads(); @@ -468,8 +468,6 @@ public class MamMigrationSelective implements CommandLineRunner { uploadFilesForEntry(entry, location); - // TODO process file upload errors(?) - log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson); } catch (HttpStatusCodeException hsce) { @@ -551,16 +549,16 @@ public class MamMigrationSelective implements CommandLineRunner { log.debug("Storing upload token " + result.token); UploadReference reference = new UploadReference(); reference.targetRecord = recordLocation; -// reference.isMaster = isMaster; + reference.isMaster = isMaster; reference.token = result.token; reference.filename = file.getName(); openUploads.add(reference); } else if (result.uri != null) { - log.debug("Storing upload reference URI " + result.uri); + log.debug("Storing upload reference " + result.uri); UploadReference reference = new UploadReference(); reference.targetRecord = recordLocation; -// reference.isMaster = isMaster; + reference.isMaster = isMaster; reference.uri = result.uri; reference.filename = file.getName(); openUploads.add(reference); @@ -594,17 +592,20 @@ public class MamMigrationSelective implements CommandLineRunner { for (UploadReference reference : openUploads) { if (reference.token != null) { UploadFileRecord fileRecord = new UploadFileRecord(); - fileRecord.addFile(reference.token, reference.filename); + fileRecord.addFile(reference.token, reference.filename, reference.isMaster); log.debug("Attach uploaded file to " + reference.targetRecord); HttpEntity httpEntity = new HttpEntity(fileRecord, adamHeaders); - // TODO HIER GEHT'S WEITER - mal mit Browser testen // TODO E:\56942 wieder herstellen - Void response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class).getBody(); - - // TODO - log.debug("Response: " + response); + try { + 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(); + } 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 4380259..1e76ac1 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/UploadReference.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/UploadReference.java @@ -9,6 +9,6 @@ public class UploadReference { String token; String filename; -// String isMaster; + boolean isMaster; } diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/UploadFileRecord.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/UploadFileRecord.java index ddee62d..5da137b 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/adam/UploadFileRecord.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/UploadFileRecord.java @@ -34,13 +34,12 @@ public class UploadFileRecord { } public static class Files { -// public String master; + public String master; public List addOrUpdate = new ArrayList(); } public UploadFileRecord(String masterToken, String masterFilename) { -// files.master = masterToken; - addFile(masterToken, masterFilename); + addFile(masterToken, masterFilename, true); } public UploadFileRecord() { @@ -49,7 +48,10 @@ public class UploadFileRecord { public String contentType = "Record"; public Files files = new Files(); - public void addFile(String token, String filename) { + public void addFile(String token, String filename, boolean isMaster) { files.addOrUpdate.add(new FileContent(new Versions(new WriteFile(token, filename)))); + + if (isMaster) + files.master = token; } }