EntryDownloader - download all entry IDs

This commit is contained in:
gexce
2017-10-25 14:59:13 +02:00
parent fae7943dc6
commit 9e62fa6583
5 changed files with 12753 additions and 86 deletions
@@ -43,7 +43,7 @@ import com.bayer.edam.migration.mam.categories.CategoryTree;
import com.bayer.edam.migration.mam.categories.CategoryTree.Node;
import com.fasterxml.jackson.databind.ObjectMapper;
@SpringBootApplication
//@SpringBootApplication
@PropertySource("file:secret.properties")
public class MamMigrationSelective implements CommandLineRunner {
@@ -79,15 +79,14 @@ public class MamMigrationSelective implements CommandLineRunner {
private List<Classification> campaignYears;
private List<Campaign> campaigns = new LinkedList<Campaign>();
private List<String> locations = new ArrayList<String>();
private CategoryTree mamCategoryTree;
@Override
public void run(String... strings) throws Exception {
log.info("Write log headers");
log.info("Write log headers for " + entryLog.getAbsolutePath());
FileUtils.writeStringToFile(entryLog, "Location" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
log.info("Write log headers for " + problemLog.getAbsolutePath());
FileUtils.writeStringToFile(problemLog, "entryId" + fieldSeparator + "Entry" + lineSeparator, Charset.forName("utf-8"));
log.info("Read categories");
@@ -137,13 +136,6 @@ public class MamMigrationSelective implements CommandLineRunner {
postToAdam(entry);
}
// // delete all created records
// for (String location : locations) {
// ResponseEntity<String> response = restTemplate.exchange(adamHost + location, HttpMethod.DELETE, adamHeadersEntity,
// String.class);
// log.info("Deleted " + location + ": " + response.toString());
// }
invalidateAdamToken();
}
@@ -331,14 +323,12 @@ public class MamMigrationSelective implements CommandLineRunner {
HttpEntity<UploadRecord> httpEntity = new HttpEntity<UploadRecord>(record, adamHeaders);
try {
URI location = restTemplate.postForLocation(adamHost + "/records", httpEntity, UploadRecord.class);
log.info("Created " + location);
log.info("Entry " + entry.id + " migrated to record " + location);
FileUtils.writeStringToFile(entryLog, location.toString() + fieldSeparator + entryJson + lineSeparator,
Charset.forName("utf-8"), true);
locations.add(location.toString());
} catch (HttpStatusCodeException hsce) {
}
catch (HttpStatusCodeException hsce) {
log.error("Skipping entry " + entry.id + ": Error while creating record " + hsce.getStatusCode().toString());
log.error(hsce.getResponseBodyAsString());
FileUtils.writeStringToFile(problemLog, entry.id + fieldSeparator + entryJson + lineSeparator, Charset.forName("utf-8"), true);