Search in sources :

Example 1 with BranchDumpResult

use of com.enonic.xp.dump.BranchDumpResult in project xp by enonic.

the class RepoDumper method dumpBranch.

private void dumpBranch(Consumer<NodeId> nodeIdsAccumulator) {
    this.nodeService.refresh(RefreshMode.ALL);
    final Branch branch = ContextAccessor.current().getBranch();
    final BranchDumpResult.Builder branchDumpResult = BranchDumpResult.create(branch);
    writer.openBranchMeta(repository.getId(), branch);
    try {
        dumpBranch(branchDumpResult, nodeIdsAccumulator);
        this.dumpResult.add(branchDumpResult.build());
    } catch (Exception e) {
        throw new RepoDumpException("Error occurred when dumping repository " + repository.getId(), e);
    } finally {
        writer.closeMeta();
    }
}
Also used : BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Branch(com.enonic.xp.branch.Branch)

Example 2 with BranchDumpResult

use of com.enonic.xp.dump.BranchDumpResult in project xp by enonic.

the class DumpServiceImplTest method dumpAndLoad.

@Test
public void dumpAndLoad() throws Exception {
    final Node node = createNode(NodePath.ROOT, "myNode");
    final SystemDumpResult systemDumpResult = NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().dumpName("testDump").build()));
    final BranchDumpResult result = systemDumpResult.get(TEST_REPO_ID).get(WS_DEFAULT);
    assertNotNull(result);
    assertEquals(2, result.getSuccessful());
    NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
    final Node currentStoredNode = this.nodeService.getById(node.id());
    assertEquals(node.getTimestamp(), currentStoredNode.getTimestamp());
    assertEquals(node.id(), currentStoredNode.id());
    assertEquals(node.path(), currentStoredNode.path());
    assertEquals(node.getManualOrderValue(), currentStoredNode.getManualOrderValue());
    assertEquals(node.getAttachedBinaries(), currentStoredNode.getAttachedBinaries());
    assertEquals(node.getIndexConfigDocument(), currentStoredNode.getIndexConfigDocument());
    assertEquals(node.getChildOrder(), currentStoredNode.getChildOrder());
    assertEquals(node.getNodeState(), currentStoredNode.getNodeState());
    assertEquals(node.getNodeType(), currentStoredNode.getNodeType());
    assertEquals(node.data(), currentStoredNode.data());
}
Also used : BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Node(com.enonic.xp.node.Node) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 3 with BranchDumpResult

use of com.enonic.xp.dump.BranchDumpResult in project xp by enonic.

the class DumpServiceImplTest method zip_unzip.

@Test
public void zip_unzip() throws Exception {
    final Node node = createNode(NodePath.ROOT, "myNode");
    updateNode(node);
    updateNode(node);
    updateNode(node);
    refresh();
    final SystemDumpResult systemDumpResult = NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().archive(true).includeVersions(true).dumpName("testDump").build()));
    // 4 of node, 1 of root
    assertEquals(5, systemDumpResult.get(TEST_REPO_ID).getVersions());
    final BranchDumpResult branchDumpResult = systemDumpResult.get(TEST_REPO_ID).get(WS_DEFAULT);
    assertEquals(2, branchDumpResult.getSuccessful());
    NodeHelper.runAsAdmin(() -> this.dumpService.load(SystemLoadParams.create().archive(true).includeVersions(true).dumpName("testDump").build()));
    final Repositories newRepos = NodeHelper.runAsAdmin(this::doListRepositories);
    assertEquals(RepositoryIds.from(RepositoryId.from("com.enonic.cms.test"), RepositoryId.from("system-repo"), RepositoryId.from("system.auditlog"), RepositoryId.from("system.scheduler")), newRepos.getIds());
}
Also used : Repositories(com.enonic.xp.repository.Repositories) BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Node(com.enonic.xp.node.Node) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 4 with BranchDumpResult

use of com.enonic.xp.dump.BranchDumpResult in project xp by enonic.

the class DumpServiceImplTest method verify_result.

@Test
public void verify_result() throws Exception {
    final Node node = createNode(NodePath.ROOT, "myNode");
    updateNode(node);
    updateNode(node);
    updateNode(node);
    refresh();
    final SystemDumpResult systemDumpResult = NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().dumpName("testDump").build()));
    // 4 of node, 1 of root
    assertEquals(5, systemDumpResult.get(TEST_REPO_ID).getVersions());
    final BranchDumpResult branchDumpResult = systemDumpResult.get(TEST_REPO_ID).get(WS_DEFAULT);
    assertEquals(2, branchDumpResult.getSuccessful());
}
Also used : BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Node(com.enonic.xp.node.Node) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 5 with BranchDumpResult

use of com.enonic.xp.dump.BranchDumpResult in project xp by enonic.

the class DumpServiceImplTest method dump_long_filename.

@Test
public void dump_long_filename() throws Exception {
    final String nodeName = "this-is-my-node-with-very-long-filename-more-than-100-characters-yes-it-has-to-be-very-long-indeed-sir";
    final Node node = createNode(NodePath.ROOT, nodeName);
    final SystemDumpResult systemDumpResult = NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().dumpName("testDump").build()));
    final BranchDumpResult result = systemDumpResult.get(TEST_REPO_ID).get(WS_DEFAULT);
    assertNotNull(result);
    assertEquals(2, result.getSuccessful());
    NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
    final Node storedNode = this.nodeService.getById(node.id());
    assertNotNull(storedNode);
    assertEquals(nodeName, storedNode.name().toString());
}
Also used : BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Node(com.enonic.xp.node.Node) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

BranchDumpResult (com.enonic.xp.dump.BranchDumpResult)5 SystemDumpResult (com.enonic.xp.dump.SystemDumpResult)4 Node (com.enonic.xp.node.Node)4 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)4 Test (org.junit.jupiter.api.Test)4 Branch (com.enonic.xp.branch.Branch)1 Repositories (com.enonic.xp.repository.Repositories)1