use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class NodeServiceImpl method commit.
@Override
public NodeCommitEntry commit(final NodeCommitEntry nodeCommitEntry, final NodeIds nodeIds) {
verifyContext();
final InternalContext context = InternalContext.from(ContextAccessor.current());
final RoutableNodeVersionIds.Builder routableNodeVersionIds = RoutableNodeVersionIds.create();
final NodeBranchEntries branchNodeVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, context);
branchNodeVersions.stream().map(branchEntry -> RoutableNodeVersionId.from(branchEntry.getNodeId(), branchEntry.getVersionId())).forEach(routableNodeVersionIds::add);
return nodeStorageService.commit(nodeCommitEntry, routableNodeVersionIds.build(), context);
}
use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class PushNodesCommand method updateTargetChildrenMetaData.
private void updateTargetChildrenMetaData(final NodeBranchEntry nodeBranchEntry, PushNodesResult.Builder resultBuilder) {
final Context context = ContextAccessor.current();
final Context targetContext = ContextBuilder.create().authInfo(context.getAuthInfo()).branch(this.target).repositoryId(context.getRepositoryId()).build();
final FindNodesByParentResult result = FindNodesByParentCommand.create(this).params(FindNodesByParentParams.create().parentPath(nodeBranchEntry.getNodePath()).childOrder(ChildOrder.from(NodeIndexPath.PATH + " asc")).build()).build().execute();
final NodeBranchEntries childEntries = this.nodeStorageService.getBranchNodeVersions(result.getNodeIds(), false, InternalContext.from(ContextAccessor.current()));
for (final NodeBranchEntry child : childEntries) {
final NodeBranchEntry targetNodeEntry = this.nodeStorageService.getBranchNodeVersion(child.getNodeId(), InternalContext.from(targetContext));
if (targetNodeEntry != null) {
final Node childNode = GetNodeByIdCommand.create(this).id(child.getNodeId()).build().execute();
this.nodeStorageService.move(StoreMovedNodeParams.create().nodeVersionId(child.getVersionId()).node(childNode).build(), InternalContext.from(targetContext));
resultBuilder.addSuccess(child);
updateTargetChildrenMetaData(child, resultBuilder);
}
}
}
use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class PushNodesCommand method execute.
public InternalPushNodesResult execute() {
final Context context = ContextAccessor.current();
refresh();
final NodeBranchEntries nodeBranchEntries = getNodeBranchEntries();
final NodeComparisons comparisons = getNodeComparisons(nodeBranchEntries);
final InternalPushNodesResult.Builder builder = pushNodes(context, nodeBranchEntries, comparisons);
refresh();
return builder.build();
}
use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class ResolveSyncWorkCommand method markChildrenForDeletion.
private void markChildrenForDeletion(final NodeComparison comparison) {
final FindNodesByParentResult result = FindNodeIdsByParentCommand.create(this).size(NodeSearchService.GET_ALL_SIZE_FLAG).parentId(comparison.getNodeId()).childOrder(ChildOrder.from(NodeIndexPath.PATH + " asc")).recursive(true).build().execute();
final NodeBranchEntries brancEntries = this.nodeStorageService.getBranchNodeVersions(result.getNodeIds(), false, InternalContext.from(ContextAccessor.current()));
addToResult(NodeComparisons.create().addAll(brancEntries.stream().map((branchEntry) -> new NodeComparison(branchEntry, branchEntry, CompareStatus.PENDING_DELETE)).collect(Collectors.toSet())).build());
}
use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class MoveNodeCommand method doMoveNode.
private Node doMoveNode(final NodePath newParentPath, final NodeName newNodeName, final NodeId id) {
final Node persistedNode = doGetById(id);
final SearchResult result = this.nodeSearchService.query(NodeQuery.create().parent(persistedNode.path()).from(0).size(NodeSearchService.GET_ALL_SIZE_FLAG).build(), SingleRepoSearchSource.from(ContextAccessor.current()));
final NodeBranchEntries nodeBranchEntries = this.nodeStorageService.getBranchNodeVersions(NodeIds.from(result.getIds()), false, InternalContext.from(ContextAccessor.current()));
final Node.Builder nodeToMoveBuilder = Node.create(persistedNode).name(newNodeName).data(processor.process(persistedNode.data())).parentPath(newParentPath).indexConfigDocument(persistedNode.getIndexConfigDocument()).timestamp(Instant.now(CLOCK));
final Node movedNode;
final boolean isTheOriginalMovedNode = persistedNode.id().equals(this.nodeId);
if (isTheOriginalMovedNode) {
final boolean isRenaming = newParentPath.equals(persistedNode.parentPath());
if (!isRenaming) {
updateStoredNodeProperties(newParentPath, nodeToMoveBuilder);
}
}
movedNode = doStore(nodeToMoveBuilder.build());
this.result.addMovedNode(MoveNodeResult.MovedNode.create().previousPath(persistedNode.path()).node(movedNode).build());
nodeMoved(1);
for (final NodeBranchEntry nodeBranchEntry : nodeBranchEntries) {
doMoveNode(nodeToMoveBuilder.build().path(), getNodeName(nodeBranchEntry), nodeBranchEntry.getNodeId());
}
return movedNode;
}
Aggregations