|
|
|
@@ -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<Long>(entryMap.keySet());
|
|
|
|
|
// entrySelection = new ArrayList<Long>(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<Long>();
|
|
|
|
@@ -557,15 +558,14 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|
|
|
|
// Create record
|
|
|
|
|
HttpEntity<UploadRecord> httpEntity = new HttpEntity<UploadRecord>(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<String>("", 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 {
|
|
|
|
|