Search in sources :

Example 1 with FindNodesByParentResult

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

the class FindContentByParentCommand method execute.

FindContentByParentResult execute() {
    final FindNodesByParentResult result = nodeService.findByParent(createFindNodesByParentParams());
    final Nodes nodes = this.nodeService.getByIds(result.getNodeIds());
    final Contents contents = this.translator.fromNodes(nodes, true);
    return FindContentByParentResult.create().contents(contents).totalHits(result.getTotalHits()).hits(result.getHits()).build();
}
Also used : Contents(com.enonic.xp.content.Contents) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Nodes(com.enonic.xp.node.Nodes)

Example 2 with FindNodesByParentResult

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

the class RestoreContentCommand method updateProperties.

private void updateProperties(final Node node, final boolean isRootContent) {
    final FindNodesByParentResult childrenToRestore = nodeService.findByParent(FindNodesByParentParams.create().size(-1).recursive(true).parentId(node.id()).build());
    childrenToRestore.getNodeIds().forEach(id -> nodeService.update(UpdateNodeParams.create().id(id).editor(toBeEdited -> {
        toBeEdited.data.removeProperties(ARCHIVED_TIME);
        toBeEdited.data.removeProperties(ARCHIVED_BY);
    }).build()));
    if (isRootContent) {
        nodeService.update(UpdateNodeParams.create().id(node.id()).editor(toBeEdited -> {
            toBeEdited.data.removeProperties(ORIGINAL_PARENT_PATH);
            toBeEdited.data.removeProperties(ORIGINAL_NAME);
            toBeEdited.data.removeProperties(ARCHIVED_TIME);
            toBeEdited.data.removeProperties(ARCHIVED_BY);
        }).build());
    }
}
Also used : RefreshMode(com.enonic.xp.node.RefreshMode) MoveNodeException(com.enonic.xp.node.MoveNodeException) ContentConstants(com.enonic.xp.content.ContentConstants) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) Node(com.enonic.xp.node.Node) ORIGINAL_PARENT_PATH(com.enonic.xp.content.ContentPropertyNames.ORIGINAL_PARENT_PATH) ORIGINAL_NAME(com.enonic.xp.content.ContentPropertyNames.ORIGINAL_NAME) RestoreContentParams(com.enonic.xp.archive.RestoreContentParams) ContentId(com.enonic.xp.content.ContentId) RestoreContentException(com.enonic.xp.archive.RestoreContentException) ContextAccessor(com.enonic.xp.context.ContextAccessor) EnumSet(java.util.EnumSet) Property(com.enonic.xp.data.Property) ContentAccessException(com.enonic.xp.content.ContentAccessException) ArchiveConstants(com.enonic.xp.archive.ArchiveConstants) ContentInheritType(com.enonic.xp.content.ContentInheritType) NodePath(com.enonic.xp.node.NodePath) ARCHIVED_BY(com.enonic.xp.content.ContentPropertyNames.ARCHIVED_BY) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) NodeId(com.enonic.xp.node.NodeId) MoveNodeListener(com.enonic.xp.node.MoveNodeListener) RenameNodeParams(com.enonic.xp.node.RenameNodeParams) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) NodeName(com.enonic.xp.node.NodeName) RestoreContentListener(com.enonic.xp.archive.RestoreContentListener) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) NodeAccessException(com.enonic.xp.node.NodeAccessException) Preconditions(com.google.common.base.Preconditions) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) MoveNodeParams(com.enonic.xp.node.MoveNodeParams) ARCHIVED_TIME(com.enonic.xp.content.ContentPropertyNames.ARCHIVED_TIME) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Example 3 with FindNodesByParentResult

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

the class UnpublishContentCommand method recursiveUnpublish.

private void recursiveUnpublish(final NodeId nodeId, boolean includeChildren, final ContentIds.Builder contentsBuilder) {
    if (includeChildren) {
        final FindNodesByParentResult result = this.nodeService.findByParent(FindNodesByParentParams.create().parentId(nodeId).build());
        result.getNodeIds().forEach((id) -> recursiveUnpublish(id, true, contentsBuilder));
    }
    final NodeIds nodes = this.nodeService.deleteById(nodeId);
    if (nodes != null && nodes.isNotEmpty()) {
        if (params.getPublishContentListener() != null) {
            params.getPublishContentListener().contentPushed(1);
        }
        contentsBuilder.add(ContentId.from(nodes.first().toString()));
    }
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Example 4 with FindNodesByParentResult

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

the class RepoDumper method dumpBranch.

private void dumpBranch(final BranchDumpResult.Builder dumpResult, Consumer<NodeId> nodeIdsAccumulator) {
    final Node rootNode = this.nodeService.getRoot();
    final FindNodesByParentResult children = this.nodeService.findByParent(FindNodesByParentParams.create().parentId(rootNode.id()).recursive(true).childOrder(ChildOrder.from("_path asc")).build());
    final Branch branch = ContextAccessor.current().getBranch();
    this.listener.dumpingBranch(repository.getId(), branch, children.getTotalHits() + 1);
    LOG.info("Dumping repository [{}], branch [{}]", repository.getId(), branch);
    doDumpNode(rootNode.id(), dumpResult);
    nodeIdsAccumulator.accept(rootNode.id());
    for (final NodeId child : children.getNodeIds()) {
        doDumpNode(child, dumpResult);
        nodeIdsAccumulator.accept(child);
    }
}
Also used : Branch(com.enonic.xp.branch.Branch) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Example 5 with FindNodesByParentResult

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

the class AbstractDeleteNodeCommand method newResolveNodesToDelete.

private NodeBranchEntries newResolveNodesToDelete(final Node node) {
    final FindNodeIdsByParentCommand command = FindNodeIdsByParentCommand.create(this).parentPath(node.path()).recursive(true).childOrder(ChildOrder.reversePath()).size(NodeSearchService.GET_ALL_SIZE_FLAG).build();
    final FindNodesByParentResult result = command.execute();
    final NodeIds nodeIds = NodeIds.create().addAll(result.getNodeIds()).add(node.id()).build();
    return FindNodeBranchEntriesByIdCommand.create(command).ids(nodeIds).orderExpressions(ChildOrder.reversePath().getOrderExpressions()).build().execute();
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Aggregations

FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)39 Node (com.enonic.xp.node.Node)28 Test (org.junit.jupiter.api.Test)17 NodeId (com.enonic.xp.node.NodeId)14 Nodes (com.enonic.xp.node.Nodes)9 FindNodesByParentParams (com.enonic.xp.node.FindNodesByParentParams)5 Context (com.enonic.xp.context.Context)3 ContextAccessor (com.enonic.xp.context.ContextAccessor)3 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)3 RefreshMode (com.enonic.xp.node.RefreshMode)3 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)3 ArchiveConstants (com.enonic.xp.archive.ArchiveConstants)2 Branch (com.enonic.xp.branch.Branch)2 ContentAccessException (com.enonic.xp.content.ContentAccessException)2 ContentConstants (com.enonic.xp.content.ContentConstants)2 ContentIds (com.enonic.xp.content.ContentIds)2 ContentInheritType (com.enonic.xp.content.ContentInheritType)2 ARCHIVED_BY (com.enonic.xp.content.ContentPropertyNames.ARCHIVED_BY)2 ARCHIVED_TIME (com.enonic.xp.content.ContentPropertyNames.ARCHIVED_TIME)2 ORIGINAL_NAME (com.enonic.xp.content.ContentPropertyNames.ORIGINAL_NAME)2