use of com.enonic.xp.node.NodeCommitQuery in project xp by enonic.
the class RepoDumper method dumpCommits.
private void dumpCommits() {
writer.openCommitsMeta(repository.getId());
try {
final NodeCommitQuery nodeCommitQuery = NodeCommitQuery.create().size(-1).build();
final NodeCommitEntries nodeCommitEntries = this.nodeService.findCommits(nodeCommitQuery).getNodeCommitEntries();
nodeCommitEntries.stream().map(nodeCommitEntry -> CommitDumpEntry.create().nodeCommitId(nodeCommitEntry.getNodeCommitId()).message(nodeCommitEntry.getMessage()).committer(nodeCommitEntry.getCommitter()).timestamp(nodeCommitEntry.getTimestamp()).build()).forEach(writer::writeCommitEntry);
} finally {
writer.closeMeta();
}
}
use of com.enonic.xp.node.NodeCommitQuery in project xp by enonic.
the class DumpServiceImplTest method checkCommitUpgrade.
private void checkCommitUpgrade(final NodeId nodeId) {
nodeService.refresh(RefreshMode.ALL);
final NodeCommitQuery nodeCommitQuery = NodeCommitQuery.create().build();
final NodeCommitQueryResult nodeCommitQueryResult = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("master")).build().callWith(() -> nodeService.findCommits(nodeCommitQuery));
assertEquals(1, nodeCommitQueryResult.getTotalHits());
final NodeCommitEntry commitEntry = nodeCommitQueryResult.getNodeCommitEntries().iterator().next();
final NodeCommitId nodeCommitId = commitEntry.getNodeCommitId();
assertEquals("Dump upgrade", commitEntry.getMessage());
assertEquals("user:system:node-su", commitEntry.getCommitter().toString());
final GetActiveNodeVersionsParams activeNodeVersionsParams = GetActiveNodeVersionsParams.create().nodeId(nodeId).branches(Branches.from(ContentConstants.BRANCH_DRAFT, ContentConstants.BRANCH_MASTER)).build();
final GetActiveNodeVersionsResult activeNodeVersionsResult = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("master")).build().callWith(() -> nodeService.getActiveVersions(activeNodeVersionsParams));
final NodeVersionMetadata draftNodeVersion = activeNodeVersionsResult.getNodeVersions().get(ContentConstants.BRANCH_DRAFT);
assertNull(draftNodeVersion.getNodeCommitId());
final NodeVersionMetadata masterNodeVersion = activeNodeVersionsResult.getNodeVersions().get(ContentConstants.BRANCH_MASTER);
assertEquals(nodeCommitId, masterNodeVersion.getNodeCommitId());
final NodeVersionQuery nodeVersionQuery = NodeVersionQuery.create().nodeId(nodeId).build();
final NodeVersionQueryResult versionQueryResult = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("draft")).build().callWith(() -> nodeService.findVersions(nodeVersionQuery));
assertEquals(16, versionQueryResult.getTotalHits());
}
Aggregations