Search in sources :

Example 21 with FindNodesByParentResult

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

the class RepositoryEntryServiceImpl method findRepositoryEntryIds.

@Override
public RepositoryIds findRepositoryEntryIds() {
    final ImmutableList.Builder<RepositoryId> repositoryIds = ImmutableList.builder();
    final FindNodesByParentParams findNodesByParentParams = FindNodesByParentParams.create().parentPath(RepositoryConstants.REPOSITORY_STORAGE_PARENT_PATH).size(-1).build();
    final FindNodesByParentResult findNodesByParentResult = createContext().callWith(() -> FindNodesByParentCommand.create().params(findNodesByParentParams).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).build().execute());
    findNodesByParentResult.getNodeIds().stream().map(nodeId -> RepositoryId.from(nodeId.toString())).forEach(repositoryIds::add);
    return RepositoryIds.from(repositoryIds.build());
}
Also used : RefreshMode(com.enonic.xp.node.RefreshMode) NodeStorageService(com.enonic.xp.repo.impl.storage.NodeStorageService) EventPublisher(com.enonic.xp.event.EventPublisher) Node(com.enonic.xp.node.Node) RepositoryIds(com.enonic.xp.repository.RepositoryIds) Branch(com.enonic.xp.branch.Branch) Component(org.osgi.service.component.annotations.Component) RepositoryId(com.enonic.xp.repository.RepositoryId) ImmutableList(com.google.common.collect.ImmutableList) UpdateNodeCommand(com.enonic.xp.repo.impl.node.UpdateNodeCommand) ContextAccessor(com.enonic.xp.context.ContextAccessor) RefreshCommand(com.enonic.xp.repo.impl.node.RefreshCommand) NodeEvents(com.enonic.xp.repo.impl.NodeEvents) ContextBuilder(com.enonic.xp.context.ContextBuilder) ByteSource(com.google.common.io.ByteSource) SystemConstants(com.enonic.xp.security.SystemConstants) RepositoryEvents(com.enonic.xp.repo.impl.RepositoryEvents) FindNodesByParentCommand(com.enonic.xp.repo.impl.node.FindNodesByParentCommand) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeSearchService(com.enonic.xp.repo.impl.search.NodeSearchService) AttachedBinary(com.enonic.xp.node.AttachedBinary) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) BinaryService(com.enonic.xp.repo.impl.binary.BinaryService) IndexServiceInternal(com.enonic.xp.repo.impl.index.IndexServiceInternal) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) DeleteNodeByIdCommand(com.enonic.xp.repo.impl.node.DeleteNodeByIdCommand) Context(com.enonic.xp.context.Context) Reference(org.osgi.service.component.annotations.Reference) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) RepositoryConstants(com.enonic.xp.repository.RepositoryConstants) Repository(com.enonic.xp.repository.Repository) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) ImmutableList(com.google.common.collect.ImmutableList) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 22 with FindNodesByParentResult

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

the class DuplicateNodeCommandTest method assertOrder.

private void assertOrder(final Node parentNode, final String first, final String second, final String third) {
    final FindNodesByParentResult children = findChildren(parentNode);
    final Iterator<NodeId> iterator = children.getNodeIds().iterator();
    assertEquals(first, getNode(iterator.next()).name().toString());
    assertEquals(second, getNode(iterator.next()).name().toString());
    assertEquals(third, getNode(iterator.next()).name().toString());
}
Also used : NodeId(com.enonic.xp.node.NodeId) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult)

Example 23 with FindNodesByParentResult

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

the class DuplicateNodeCommand method updateChildReferences.

private void updateChildReferences(final Node duplicatedParent, final NodeReferenceUpdatesHolder nodeReferenceUpdatesHolder) {
    final FindNodesByParentResult findNodesByParentResult = doFindNodesByParent(FindNodesByParentParams.create().parentPath(duplicatedParent.path()).from(0).size(NodeSearchService.GET_ALL_SIZE_FLAG).build());
    final Nodes children = GetNodesByIdsCommand.create(this).ids(findNodesByParentResult.getNodeIds()).build().execute();
    for (final Node node : children) {
        updateNodeReferences(node, nodeReferenceUpdatesHolder);
        updateChildReferences(node, nodeReferenceUpdatesHolder);
    }
}
Also used : Node(com.enonic.xp.node.Node) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Nodes(com.enonic.xp.node.Nodes)

Example 24 with FindNodesByParentResult

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

the class ApplyNodePermissionsCommand method applyPermissionsToChildren.

private void applyPermissionsToChildren(final Node parent) {
    final AccessControlList parentPermissions = parent.getPermissions();
    final FindNodesByParentParams findByParentParams = FindNodesByParentParams.create().parentPath(parent.path()).size(NodeSearchService.GET_ALL_SIZE_FLAG).build();
    final FindNodesByParentResult result = doFindNodesByParent(findByParentParams);
    final Nodes children = GetNodesByIdsCommand.create(this).ids(result.getNodeIds()).build().execute();
    for (Node child : children) {
        applyPermissions(parentPermissions, child);
    }
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) Node(com.enonic.xp.node.Node) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Nodes(com.enonic.xp.node.Nodes)

Example 25 with FindNodesByParentResult

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

the class SetNodeChildOrderCommandTest method order_by_name_asc.

@Test
public void order_by_name_asc() throws Exception {
    final FindNodesByParentResult result = createNodeAndReturnOrderedChildren(NodeIndexPath.NAME, OrderExpr.Direction.ASC);
    String previousName = "";
    for (final NodeId n : result.getNodeIds()) {
        final Node node = getNode(n);
        final boolean smallerThanPreviousName = previousName.compareTo(node.name().toString()) < 0;
        assertTrue(Objects.equals(previousName, "") || smallerThanPreviousName);
        previousName = node.name().toString();
    }
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Test(org.junit.jupiter.api.Test)

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