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