Search in sources :

Example 1 with BranchDumpEntry

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()));
    }
}
Also used : BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry)

Example 2 with BranchDumpEntry

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();
}
Also used : NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Node(com.enonic.xp.node.Node) BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry) AttachedBinary(com.enonic.xp.node.AttachedBinary)

Example 3 with BranchDumpEntry

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;
}
Also used : VersionMeta(com.enonic.xp.repo.impl.dump.model.VersionMeta) BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry)

Example 4 with BranchDumpEntry

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());
}
Also used : Node(com.enonic.xp.node.Node) BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 5 with BranchDumpEntry

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());
}
Also used : Node(com.enonic.xp.node.Node) BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

BranchDumpEntry (com.enonic.xp.repo.impl.dump.model.BranchDumpEntry)6 Node (com.enonic.xp.node.Node)3 Test (org.junit.jupiter.api.Test)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)1 VersionMeta (com.enonic.xp.repo.impl.dump.model.VersionMeta)1