Search in sources :

Example 11 with NodeBranchEntries

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);
}
Also used : RoutableNodeVersionIds(com.enonic.xp.node.RoutableNodeVersionIds) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) FindNodePathsByQueryResult(com.enonic.xp.node.FindNodePathsByQueryResult) NodePaths(com.enonic.xp.node.NodePaths) Nodes(com.enonic.xp.node.Nodes) SetNodeStateResult(com.enonic.xp.node.SetNodeStateResult) FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) RepositoryService(com.enonic.xp.repository.RepositoryService) NodeComparison(com.enonic.xp.node.NodeComparison) NodesHasChildrenResult(com.enonic.xp.node.NodesHasChildrenResult) Branch(com.enonic.xp.branch.Branch) Trace(com.enonic.xp.trace.Trace) NodeCommitId(com.enonic.xp.node.NodeCommitId) RepositoryId(com.enonic.xp.repository.RepositoryId) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeService(com.enonic.xp.node.NodeService) PushNodesResult(com.enonic.xp.node.PushNodesResult) BinaryReference(com.enonic.xp.util.BinaryReference) NodeSearchService(com.enonic.xp.repo.impl.search.NodeSearchService) CreateRootNodeParams(com.enonic.xp.node.CreateRootNodeParams) NodeComparisons(com.enonic.xp.node.NodeComparisons) AccessControlList(com.enonic.xp.security.acl.AccessControlList) Collectors(java.util.stream.Collectors) NodeId(com.enonic.xp.node.NodeId) RenameNodeParams(com.enonic.xp.node.RenameNodeParams) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) OrderExpr(com.enonic.xp.query.expr.OrderExpr) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) MoveNodeResult(com.enonic.xp.node.MoveNodeResult) BinaryService(com.enonic.xp.repo.impl.binary.BinaryService) ImportNodeVersionParams(com.enonic.xp.node.ImportNodeVersionParams) ReorderChildNodesResult(com.enonic.xp.node.ReorderChildNodesResult) IndexServiceInternal(com.enonic.xp.repo.impl.index.IndexServiceInternal) NodeVersion(com.enonic.xp.node.NodeVersion) Context(com.enonic.xp.context.Context) ApplyNodePermissionsResult(com.enonic.xp.node.ApplyNodePermissionsResult) LoadNodeResult(com.enonic.xp.node.LoadNodeResult) NodeCommitQuery(com.enonic.xp.node.NodeCommitQuery) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) PushNodesListener(com.enonic.xp.node.PushNodesListener) SyncWorkResolverParams(com.enonic.xp.node.SyncWorkResolverParams) Repository(com.enonic.xp.repository.Repository) RefreshMode(com.enonic.xp.node.RefreshMode) NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) NodeStorageService(com.enonic.xp.repo.impl.storage.NodeStorageService) EventPublisher(com.enonic.xp.event.EventPublisher) RoutableNodeVersionIds(com.enonic.xp.node.RoutableNodeVersionIds) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) MultiRepoNodeQuery(com.enonic.xp.node.MultiRepoNodeQuery) GetActiveNodeVersionsParams(com.enonic.xp.node.GetActiveNodeVersionsParams) Node(com.enonic.xp.node.Node) DuplicateNodeParams(com.enonic.xp.node.DuplicateNodeParams) NodeCommitQueryResult(com.enonic.xp.node.NodeCommitQueryResult) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) ReorderChildNodesParams(com.enonic.xp.node.ReorderChildNodesParams) GetActiveNodeVersionsResult(com.enonic.xp.node.GetActiveNodeVersionsResult) ImportNodeResult(com.enonic.xp.node.ImportNodeResult) ImportNodeCommitParams(com.enonic.xp.node.ImportNodeCommitParams) Component(org.osgi.service.component.annotations.Component) SetNodeChildOrderParams(com.enonic.xp.node.SetNodeChildOrderParams) Tracer(com.enonic.xp.trace.Tracer) NodeVersionId(com.enonic.xp.node.NodeVersionId) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) NodeEvents(com.enonic.xp.repo.impl.NodeEvents) FieldOrderExpr(com.enonic.xp.query.expr.FieldOrderExpr) Activate(org.osgi.service.component.annotations.Activate) ByteSource(com.google.common.io.ByteSource) NodeQuery(com.enonic.xp.node.NodeQuery) VersionIndexPath(com.enonic.xp.repo.impl.version.VersionIndexPath) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodePath(com.enonic.xp.node.NodePath) GetNodeVersionsParams(com.enonic.xp.node.GetNodeVersionsParams) MoveNodeListener(com.enonic.xp.node.MoveNodeListener) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) ImportNodeParams(com.enonic.xp.node.ImportNodeParams) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) SetNodeStateParams(com.enonic.xp.node.SetNodeStateParams) BranchNotFoundException(com.enonic.xp.repository.BranchNotFoundException) ApplyNodePermissionsParams(com.enonic.xp.node.ApplyNodePermissionsParams) DeleteNodeListener(com.enonic.xp.node.DeleteNodeListener) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Reference(org.osgi.service.component.annotations.Reference) LoadNodeParams(com.enonic.xp.node.LoadNodeParams) MoveNodeParams(com.enonic.xp.node.MoveNodeParams) NodeIds(com.enonic.xp.node.NodeIds) RepositoryNotFoundException(com.enonic.xp.repository.RepositoryNotFoundException) InternalContext(com.enonic.xp.repo.impl.InternalContext)

Example 12 with NodeBranchEntries

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);
        }
    }
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) Node(com.enonic.xp.node.Node) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 13 with NodeBranchEntries

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();
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeComparisons(com.enonic.xp.node.NodeComparisons)

Example 14 with NodeBranchEntries

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());
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeComparison(com.enonic.xp.node.NodeComparison) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Example 15 with NodeBranchEntries

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;
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) Node(com.enonic.xp.node.Node) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Aggregations

NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)16 Node (com.enonic.xp.node.Node)7 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)7 InternalContext (com.enonic.xp.repo.impl.InternalContext)7 NodeId (com.enonic.xp.node.NodeId)5 Context (com.enonic.xp.context.Context)4 NodeIds (com.enonic.xp.node.NodeIds)4 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)3 NodeComparison (com.enonic.xp.node.NodeComparison)3 NodeComparisons (com.enonic.xp.node.NodeComparisons)3 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)3 NodePath (com.enonic.xp.node.NodePath)3 NodePaths (com.enonic.xp.node.NodePaths)3 NodeVersion (com.enonic.xp.node.NodeVersion)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 Branch (com.enonic.xp.branch.Branch)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeCommitId (com.enonic.xp.node.NodeCommitId)2 NodeVersionId (com.enonic.xp.node.NodeVersionId)2