use of com.enonic.xp.repo.impl.dump.upgrade.DumpUpgradeException in project xp by enonic.
the class FlattenedPageDumpUpgrader method upgradeBranch.
private void upgradeBranch(final Branch branch) {
final Path branchEntriesFile = dumpReader.getBranchEntriesFile(REPOSITORY_ID, branch);
if (Files.exists(branchEntriesFile)) {
// Gathers the template -> controller mappings
final TemplateControllerMappings templateControllerMappings = new TemplateControllerMappings();
processEntries((entryContent, entryName) -> {
final Pre4BranchDumpEntryJson sourceEntry = deserializeValue(entryContent, Pre4BranchDumpEntryJson.class);
addTemplateControllerMapping(sourceEntry.getMeta(), templateControllerMappings);
}, branchEntriesFile);
final Map<String, String> templateControllerMap = templateControllerMappings.getMappings();
// Update contents with pages
final FlattenedPageDataUpgrader dataUpgrader = FlattenedPageDataUpgrader.create().templateControllerMap(templateControllerMap).build();
processEntries((entryContent, entryName) -> {
result.processed();
try {
final Pre4BranchDumpEntryJson sourceEntry = deserializeValue(entryContent, Pre4BranchDumpEntryJson.class);
upgradeVersionMeta(sourceEntry.getMeta(), dataUpgrader);
} catch (Exception e) {
result.error();
LOG.error("Error while upgrading branch entry [" + entryName + "]", e);
}
}, branchEntriesFile);
} else {
throw new DumpUpgradeException("Branch entries file missing for repository [" + REPOSITORY_ID + "] and branch [" + branch + "]");
}
}
Aggregations