use of com.enonic.xp.repo.impl.dump.model.BranchDumpEntry in project xp by enonic.
the class RepoDumper method doDumpNode.
private void doDumpNode(final NodeId nodeId, final BranchDumpResult.Builder dumpResult) {
try {
final BranchDumpEntry branchDumpEntry = createDumpEntry(nodeId);
writer.writeBranchEntry(branchDumpEntry);
writer.writeNodeVersionBlobs(repository.getId(), branchDumpEntry.getMeta().getNodeVersionKey());
writeBinaries(dumpResult, branchDumpEntry.getBinaryReferences());
dumpResult.addedNode();
this.listener.nodeDumped();
} catch (Exception e) {
dumpResult.error(DumpError.error("Cannot dump node with id [" + nodeId + "]: " + e.getMessage()));
}
}
use of com.enonic.xp.repo.impl.dump.model.BranchDumpEntry in project xp by enonic.
the class RepoDumper method createDumpEntry.
private BranchDumpEntry createDumpEntry(final NodeId nodeId) {
final BranchDumpEntry.Builder builder = BranchDumpEntry.create().nodeId(nodeId);
final Node currentNode = this.nodeService.getById(nodeId);
final NodeVersionMetadata currentVersionMetaData = getActiveVersion(nodeId);
builder.meta(VersionMetaFactory.create(currentNode, currentVersionMetaData));
if (this.includeBinaries) {
builder.addBinaryReferences(currentNode.getAttachedBinaries().stream().map(AttachedBinary::getBlobKey).collect(Collectors.toSet()));
}
return builder.build();
}
use of com.enonic.xp.repo.impl.dump.model.BranchDumpEntry in project xp by enonic.
the class BranchEntryProcessor method processLine.
@Override
public boolean processLine(final String line) throws IOException {
final EntryLoadResult.Builder result = EntryLoadResult.create();
final BranchDumpEntry branchDumpEntry = this.serializer.toBranchMetaEntry(line);
final VersionMeta meta = branchDumpEntry.getMeta();
addNode(result, branchDumpEntry, meta);
this.result = result.build();
return true;
}
use of com.enonic.xp.repo.impl.dump.model.BranchDumpEntry in project xp by enonic.
the class RepoDumperTest method children.
@Test
public void children() throws Exception {
final Node node1 = createNode(NodePath.ROOT, "myNode");
createNode(node1.path(), "myChild");
createNode(node1.path(), "myChild2");
createNode(node1.path(), "myChild3");
refresh();
final TestDumpWriter writer = new TestDumpWriter();
doDump(writer);
final List<BranchDumpEntry> dumpEntries = writer.get(TEST_REPO_ID, ctxDefault().getBranch());
assertEquals(5, dumpEntries.size());
}
use of com.enonic.xp.repo.impl.dump.model.BranchDumpEntry in project xp by enonic.
the class RepoDumperTest method node_versions_stored.
@Test
public void node_versions_stored() throws Exception {
final Node node1 = createNode(NodePath.ROOT, "myNode");
updateNode(UpdateNodeParams.create().id(node1.id()).editor((node) -> node.data.setString("fisk", "Ost")).build());
final TestDumpWriter writer = new TestDumpWriter();
doDump(writer);
final List<BranchDumpEntry> dumpEntries = writer.get(TEST_REPO_ID, ctxDefault().getBranch());
assertEquals(2, dumpEntries.size());
// 2 versions for the root node on draft and master + 2 versions of the node
assertEquals(4, writer.getNodeVersionKeys().size());
}
Aggregations