use of com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4VersionsDumpEntryJson in project xp by enonic.
the class FlattenedPageDumpUpgrader method doUpgrade.
@Override
public void doUpgrade(final String dumpName) {
super.doUpgrade(dumpName);
final Path versionsFile = dumpReader.getVersionsFile(REPOSITORY_ID);
if (Files.exists(versionsFile)) {
// Gathers the template -> controller mappings
final TemplateControllerMappings templateControllerMappings = new TemplateControllerMappings();
processEntries((entryContent, entryName) -> {
final Pre4VersionsDumpEntryJson sourceEntry = deserializeValue(entryContent, Pre4VersionsDumpEntryJson.class);
final Pre4VersionDumpEntryJson sourceVersion = sourceEntry.getVersions().stream().findFirst().get();
addTemplateControllerMapping(sourceVersion, templateControllerMappings);
}, versionsFile);
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 Pre4VersionsDumpEntryJson sourceEntry = deserializeValue(entryContent, Pre4VersionsDumpEntryJson.class);
sourceEntry.getVersions().forEach(version -> upgradeVersionMeta(version, dataUpgrader));
} catch (Exception e) {
result.error();
LOG.error("Error while upgrading version entry [" + entryName + "]", e);
}
}, versionsFile);
} else {
dumpReader.getBranches(REPOSITORY_ID).forEach(this::upgradeBranch);
}
}
use of com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4VersionsDumpEntryJson in project xp by enonic.
the class IndexAccessSegmentsDumpUpgrader method upgradeVersionEntry.
@Override
protected byte[] upgradeVersionEntry(final RepositoryId repositoryId, final String entryContent) {
final Pre4VersionsDumpEntryJson versionsDumpEntry = deserializeValue(entryContent, Pre4VersionsDumpEntryJson.class);
Collection<Pre6VersionDumpEntryJson> versions = versionsDumpEntry.getVersions().stream().map(versionDumpEntry -> upgradeVersionDumpEntry(repositoryId, versionDumpEntry)).collect(Collectors.toList());
final Pre6VersionsDumpEntryJson upgradedVersionsDumpEntry = Pre6VersionsDumpEntryJson.create().nodeId(versionsDumpEntry.getNodeId()).versions(versions).build();
return serialize(upgradedVersionsDumpEntry);
}
Aggregations