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