Search in sources :

Example 1 with NodeCommitQuery

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();
    }
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) RefreshMode(com.enonic.xp.node.RefreshMode) NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) SystemDumpListener(com.enonic.xp.dump.SystemDumpListener) GetActiveNodeVersionsParams(com.enonic.xp.node.GetActiveNodeVersionsParams) DumpError(com.enonic.xp.dump.DumpError) Node(com.enonic.xp.node.Node) LoggerFactory(org.slf4j.LoggerFactory) BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) NodeCommitEntries(com.enonic.xp.node.NodeCommitEntries) BlobKey(com.enonic.xp.blob.BlobKey) Branch(com.enonic.xp.branch.Branch) HashSet(java.util.HashSet) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeService(com.enonic.xp.node.NodeService) NodeVersionId(com.enonic.xp.node.NodeVersionId) Duration(java.time.Duration) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) RepoDumpResult(com.enonic.xp.dump.RepoDumpResult) ContextBuilder(com.enonic.xp.context.ContextBuilder) RangeFilter(com.enonic.xp.query.filter.RangeFilter) Value(com.enonic.xp.data.Value) Logger(org.slf4j.Logger) BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry) Collection(java.util.Collection) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) Set(java.util.Set) ValueFactory(com.enonic.xp.data.ValueFactory) VersionsDumpEntry(com.enonic.xp.repo.impl.dump.model.VersionsDumpEntry) Instant(java.time.Instant) Branches(com.enonic.xp.branch.Branches) Collectors(java.util.stream.Collectors) AttachedBinary(com.enonic.xp.node.AttachedBinary) NodeId(com.enonic.xp.node.NodeId) Objects(java.util.Objects) Consumer(java.util.function.Consumer) DumpWriter(com.enonic.xp.repo.impl.dump.writer.DumpWriter) CommitDumpEntry(com.enonic.xp.repo.impl.dump.model.CommitDumpEntry) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) NodeVersion(com.enonic.xp.node.NodeVersion) Context(com.enonic.xp.context.Context) NodeCommitQuery(com.enonic.xp.node.NodeCommitQuery) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) RepositoryConstants(com.enonic.xp.repository.RepositoryConstants) Repository(com.enonic.xp.repository.Repository) NodeCommitQuery(com.enonic.xp.node.NodeCommitQuery) NodeCommitEntries(com.enonic.xp.node.NodeCommitEntries)

Example 2 with NodeCommitQuery

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());
}
Also used : NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) NodeCommitQuery(com.enonic.xp.node.NodeCommitQuery) GetActiveNodeVersionsResult(com.enonic.xp.node.GetActiveNodeVersionsResult) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) NodeCommitQueryResult(com.enonic.xp.node.NodeCommitQueryResult) NodeCommitId(com.enonic.xp.node.NodeCommitId) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) GetActiveNodeVersionsParams(com.enonic.xp.node.GetActiveNodeVersionsParams)

Aggregations

GetActiveNodeVersionsParams (com.enonic.xp.node.GetActiveNodeVersionsParams)2 NodeCommitQuery (com.enonic.xp.node.NodeCommitQuery)2 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)2 NodeVersionQuery (com.enonic.xp.node.NodeVersionQuery)2 NodeVersionQueryResult (com.enonic.xp.node.NodeVersionQueryResult)2 BlobKey (com.enonic.xp.blob.BlobKey)1 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)1 Branch (com.enonic.xp.branch.Branch)1 Branches (com.enonic.xp.branch.Branches)1 Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 Value (com.enonic.xp.data.Value)1 ValueFactory (com.enonic.xp.data.ValueFactory)1 BranchDumpResult (com.enonic.xp.dump.BranchDumpResult)1 DumpError (com.enonic.xp.dump.DumpError)1 RepoDumpResult (com.enonic.xp.dump.RepoDumpResult)1 SystemDumpListener (com.enonic.xp.dump.SystemDumpListener)1 ChildOrder (com.enonic.xp.index.ChildOrder)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1