diff --git a/AH MAM Migration/resources/Migration-Logs PROD.7z b/AH MAM Migration/resources/Migration-Logs PROD.7z new file mode 100644 index 0000000..b582350 Binary files /dev/null and b/AH MAM Migration/resources/Migration-Logs PROD.7z differ diff --git a/AH MAM Migration/resources/application.properties b/AH MAM Migration/resources/application.properties index c70dc5a..ef69f62 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-28_PROD_search.log +logging.file=application_2017-11-28_PROD_fix.log 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 f1d4c9b..99411ae 100644 --- a/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java +++ b/AH MAM Migration/src/com/bayer/edam/migration/MamMigrationSelective.java @@ -99,6 +99,7 @@ public class MamMigrationSelective implements CommandLineRunner { private int entryCounter = 0; private int skippedCounter = 0; private long lastLogin = 0; + private int searchCount = 0; private static DecimalFormat decimalFormat = new DecimalFormat("#,##0.#"); private SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); @@ -126,10 +127,10 @@ public class MamMigrationSelective implements CommandLineRunner { // XXX ---------------------------------------------------------------- // Option 1: Process all available entries - entrySelection = new ArrayList(entryMap.keySet()); +// entrySelection = new ArrayList(entryMap.keySet()); // Option 2: Process a fixed set of entry IDs -// entrySelection = Arrays.asList(34703L, 34702L, 34701L, 34700L, 34699L, 34698L, 33626L, 33623L, 33621L, 33620L, 32781L, 31114L); + entrySelection = Arrays.asList(55803L, 55802L); // Option 3: Read entry IDs from file // entrySelection = new ArrayList(); @@ -557,15 +558,14 @@ public class MamMigrationSelective implements CommandLineRunner { // Create record HttpEntity httpEntity = new HttpEntity(record, adamHeaders); try { + URI location = restTemplate.postForLocation(Definitions.adamHost + "/records", httpEntity, UploadRecord.class); + log.info("RESULT Entry " + entry.id + " migrated to record " + location); + + uploadFilesForEntry(entry, location); + log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson); + // XXX -// URI location = restTemplate.postForLocation(Definitions.adamHost + "/records", httpEntity, UploadRecord.class); -// log.info("RESULT Entry " + entry.id + " migrated to record " + location); -// -// uploadFilesForEntry(entry, location); -// log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson); - - searchForRecord(entry, entryJson); - +// searchForRecord(entry, entryJson); } catch (HttpClientErrorException hcee) { log.error("RESULT Could not create record for entry " + entry.id + ", Exception: " + hcee.getMessage() + ", " @@ -585,7 +585,7 @@ public class MamMigrationSelective implements CommandLineRunner { */ private void searchForRecord(Entry entry, String entryJson) throws URISyntaxException, IOException, ZipException { adamSearchHeaders.set("Filter", "classification.name=Migration-MAM-KW47 " + entry.id); - log.debug("Searching for: classification.name=Migration-MAM-KW47 " + entry.id); + log.debug("Searching for: 'classification.name=Migration-MAM-KW47 " + entry.id + "' (" + ++searchCount + ")"); // search the already existing record SearchRecordResult searchResult = restTemplate.exchange(Definitions.adamHost + "/records", HttpMethod.GET, new HttpEntity("", adamSearchHeaders), SearchRecordResult.class).getBody(); @@ -623,7 +623,7 @@ public class MamMigrationSelective implements CommandLineRunner { i++; } - if (fileVersion.fileName.equals(expectedFile.getName())) { + if (fileVersion != null && fileVersion.fileName.equals(expectedFile.getName())) { log.info("Found expected file for " + location.toString() + ": " + fileVersion.fileName + ", " + fileVersion.fileSize); } else { diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/FileList.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/FileList.java new file mode 100644 index 0000000..95bd002 --- /dev/null +++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/FileList.java @@ -0,0 +1,9 @@ +package com.bayer.edam.migration.adam; + +import java.util.List; + +public class FileList { + + public List items; + +} diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/FileVersions.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/FileVersions.java new file mode 100644 index 0000000..625063a --- /dev/null +++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/FileVersions.java @@ -0,0 +1,23 @@ +package com.bayer.edam.migration.adam; + +import java.util.Date; +import java.util.List; + +public class FileVersions { + + public static class FileVersion { + public String id; + public String fileName; + public Date fileCreatedOn; + public Date fileModifiedOn; + public long fileSize; + public String fileExtension; + public String comment; + public long crc32; + public Date createdOn; + } + + + public List items; + +} diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/ReadFile.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/ReadFile.java new file mode 100644 index 0000000..cd98f41 --- /dev/null +++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/ReadFile.java @@ -0,0 +1,10 @@ +package com.bayer.edam.migration.adam; + +import java.util.Date; + +public class ReadFile { + + public String id; + public Date createdOn; + +} diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/SearchRecordResult.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/SearchRecordResult.java new file mode 100644 index 0000000..7a7f4d6 --- /dev/null +++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/SearchRecordResult.java @@ -0,0 +1,11 @@ +package com.bayer.edam.migration.adam; + +import java.util.List; + +public class SearchRecordResult { + + public int page; + public int totalCount; + public List items; + +}