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();
}
}
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());
}
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());
}
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());
}
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());
}
Aggregations