Search in sources :

Example 1 with DumpUpgradeException

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 + "]");
    }
}
Also used : Path(java.nio.file.Path) Pre4BranchDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4BranchDumpEntryJson) DumpUpgradeException(com.enonic.xp.repo.impl.dump.upgrade.DumpUpgradeException) DumpUpgradeException(com.enonic.xp.repo.impl.dump.upgrade.DumpUpgradeException) IOException(java.io.IOException) RepoDumpException(com.enonic.xp.repo.impl.dump.RepoDumpException)

Aggregations

RepoDumpException (com.enonic.xp.repo.impl.dump.RepoDumpException)1 DumpUpgradeException (com.enonic.xp.repo.impl.dump.upgrade.DumpUpgradeException)1 Pre4BranchDumpEntryJson (com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4BranchDumpEntryJson)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1