Search in sources :

Example 1 with NodeBranchEntry

use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.

the class PublishContentCommand method commitPushedNodes.

private void commitPushedNodes(final NodeBranchEntries branchEntries) {
    final String commitEntryMessage = message == null ? ContentConstants.PUBLISH_COMMIT_PREFIX : String.join(ContentConstants.PUBLISH_COMMIT_PREFIX_DELIMITER, ContentConstants.PUBLISH_COMMIT_PREFIX, message);
    final NodeCommitEntry commitEntry = NodeCommitEntry.create().message(commitEntryMessage).build();
    final RoutableNodeVersionIds.Builder routableNodeVersionIds = RoutableNodeVersionIds.create();
    for (NodeBranchEntry branchEntry : branchEntries) {
        final RoutableNodeVersionId routableNodeVersionId = RoutableNodeVersionId.from(branchEntry.getNodeId(), branchEntry.getVersionId());
        routableNodeVersionIds.add(routableNodeVersionId);
    }
    nodeService.commit(commitEntry, routableNodeVersionIds.build());
}
Also used : RoutableNodeVersionIds(com.enonic.xp.node.RoutableNodeVersionIds) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 2 with NodeBranchEntry

use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.

the class BranchServiceImpl method doGetByPath.

private NodeBranchEntry doGetByPath(final NodePath nodePath, final InternalContext context) {
    final BranchDocumentId branchDocumentId = this.pathCache.get(new BranchPath(context.getRepositoryId(), context.getBranch(), nodePath));
    if (branchDocumentId != null) {
        return getFromCache(nodePath, context, branchDocumentId);
    }
    final NodeBranchQuery query = NodeBranchQuery.create().addQueryFilter(ValueFilter.create().fieldName(BranchIndexPath.PATH.getPath()).addValue(ValueFactory.newString(nodePath.toString())).build()).addQueryFilter(ValueFilter.create().fieldName(BranchIndexPath.BRANCH_NAME.getPath()).addValue(ValueFactory.newString(context.getBranch().getValue())).build()).size(1).build();
    final SearchResult result = this.searchDao.search(SearchRequest.create().searchSource(SingleRepoStorageSource.create(context.getRepositoryId(), SingleRepoStorageSource.Type.BRANCH)).returnFields(BRANCH_RETURN_FIELDS).query(query).searchPreference(context.getSearchPreference()).build());
    if (!result.isEmpty()) {
        final NodeBranchEntry nodeBranchEntry = NodeBranchVersionFactory.create(result.getHits().getFirst().getReturnValues());
        doCache(context, nodeBranchEntry.getNodePath(), nodeBranchEntry.getNodeId());
        return nodeBranchEntry;
    }
    return null;
}
Also used : BranchPath(com.enonic.xp.repo.impl.cache.BranchPath) NodeBranchQuery(com.enonic.xp.repo.impl.branch.search.NodeBranchQuery) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 3 with NodeBranchEntry

use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.

the class ReindexExecutor method doReindexBranchNew.

private void doReindexBranchNew(final RepositoryId repositoryId, final ReindexResult.Builder builder, final Branch branch) {
    final NodeBranchEntries nodeBranchEntries = GetBranchDataCommand.create().branch(branch).repositoryId(repositoryId).nodeSearchService(this.nodeSearchService).build().execute();
    if (listener != null) {
        listener.branch(repositoryId, branch, nodeBranchEntries.getSize());
    }
    for (final NodeBranchEntry nodeBranchEntry : nodeBranchEntries) {
        final InternalContext context = InternalContext.create(ContextAccessor.current()).repositoryId(repositoryId).branch(branch).build();
        final NodeVersion nodeVersion = this.nodeVersionService.get(nodeBranchEntry.getNodeVersionKey(), context);
        final Node node = NodeFactory.create(nodeVersion, nodeBranchEntry);
        this.indexDataService.store(node, context);
        builder.add(node.id());
        if (listener != null) {
            listener.branchEntry(nodeBranchEntry);
        }
    }
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeVersion(com.enonic.xp.node.NodeVersion) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 4 with NodeBranchEntry

use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.

the class AbstractCompareNodeCommand method doCompareNodeVersions.

NodeComparison doCompareNodeVersions(final Context context, final NodeId nodeId) {
    final NodeBranchEntry sourceWsVersion = nodeStorageService.getBranchNodeVersion(nodeId, InternalContext.from(context));
    final NodeBranchEntry targetWsVersion = nodeStorageService.getBranchNodeVersion(nodeId, InternalContext.create(context).branch(this.target).build());
    final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceWsVersion).target(targetWsVersion).storageService(this.nodeStorageService).build().resolve();
    return new NodeComparison(sourceWsVersion, targetWsVersion, compareStatus);
}
Also used : NodeComparison(com.enonic.xp.node.NodeComparison) CompareStatus(com.enonic.xp.content.CompareStatus) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 5 with NodeBranchEntry

use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.

the class FindNodesWithVersionDifferenceCommand method getExcludePaths.

private ExcludeEntries getExcludePaths(final InternalContext context) {
    if (this.excludes.isEmpty()) {
        return ExcludeEntries.empty();
    }
    final ExcludeEntries.Builder builder = ExcludeEntries.create();
    final NodeBranchEntries result = this.nodeStorageService.getBranchNodeVersions(excludes, false, context);
    for (final NodeBranchEntry entry : result) {
        builder.add(new ExcludeEntry(entry.getNodePath(), false));
    }
    return builder.build();
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) ExcludeEntry(com.enonic.xp.repo.impl.version.search.ExcludeEntry) ExcludeEntries(com.enonic.xp.repo.impl.version.search.ExcludeEntries) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Aggregations

NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)25 InternalContext (com.enonic.xp.repo.impl.InternalContext)9 Test (org.junit.jupiter.api.Test)8 Node (com.enonic.xp.node.Node)7 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)6 NodeId (com.enonic.xp.node.NodeId)5 NodePath (com.enonic.xp.node.NodePath)5 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)4 NodeVersion (com.enonic.xp.node.NodeVersion)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 PushNodeEntries (com.enonic.xp.node.PushNodeEntries)4 RoutableNodeVersionId (com.enonic.xp.node.RoutableNodeVersionId)4 Event (com.enonic.xp.event.Event)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3 PushNodeEntry (com.enonic.xp.node.PushNodeEntry)3 Branch (com.enonic.xp.branch.Branch)2 Context (com.enonic.xp.context.Context)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeComparison (com.enonic.xp.node.NodeComparison)2 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)2