Search in sources :

Example 36 with NodeIds

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

the class ResolveSyncWorkCommand method getParentIdsFromPaths.

private NodeIds getParentIdsFromPaths(final NodePaths parentPaths) {
    final NodeIds.Builder parentIdBuilder = NodeIds.create();
    for (final NodePath parent : parentPaths) {
        final NodeId parentId = this.nodeStorageService.getIdForPath(parent, InternalContext.from(ContextAccessor.current()));
        if (parentId == null) {
            throw new NodeNotFoundException("Cannot find parent with path [" + parent + "]");
        }
        parentIdBuilder.add(parentId);
    }
    return parentIdBuilder.build();
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeIds(com.enonic.xp.node.NodeIds) NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath)

Example 37 with NodeIds

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

the class DeleteNodeByIdCommandTest method delete_with_capital_letter_in_id.

@Test
public void delete_with_capital_letter_in_id() {
    final Node node = createNode(CreateNodeParams.create().setNodeId(NodeId.from("myNodeId")).name("myNode").parent(NodePath.ROOT).build());
    final Node childNode = createNode(CreateNodeParams.create().setNodeId(NodeId.from("myChildNodeId")).name("myChildNode").parent(node.path()).build());
    final NodeIds nodeIds = doDeleteNode(node.id());
    assertEquals(2, nodeIds.getSize());
    assertNull(getNode(node.id()));
    assertNull(getNode(childNode.id()));
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Aggregations

NodeIds (com.enonic.xp.node.NodeIds)37 Node (com.enonic.xp.node.Node)12 NodeId (com.enonic.xp.node.NodeId)11 Test (org.junit.jupiter.api.Test)11 NodePath (com.enonic.xp.node.NodePath)6 Collectors (java.util.stream.Collectors)5 CompareStatus (com.enonic.xp.content.CompareStatus)4 ContentIds (com.enonic.xp.content.ContentIds)4 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)4 NodeComparison (com.enonic.xp.node.NodeComparison)4 NodeComparisons (com.enonic.xp.node.NodeComparisons)4 NodeQuery (com.enonic.xp.node.NodeQuery)4 Branch (com.enonic.xp.branch.Branch)3 ContentId (com.enonic.xp.content.ContentId)3 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)3 Context (com.enonic.xp.context.Context)3 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 DeleteIssueCommentResult (com.enonic.xp.issue.DeleteIssueCommentResult)2