Search in sources :

Example 16 with Nodes

use of com.enonic.xp.node.Nodes 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 17 with Nodes

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

the class SetNodeStateCommand method setNodeStateWithChildren.

private Node setNodeStateWithChildren(final Node node, final SetNodeStateResult.Builder setNodeStateResultBuilder) {
    final Node updatedNode = setNodeState(node, setNodeStateResultBuilder);
    final FindNodesByParentResult result = doFindNodesByParent(FindNodesByParentParams.create().parentPath(node.path()).size(NodeSearchService.GET_ALL_SIZE_FLAG).build());
    final Nodes children = GetNodesByIdsCommand.create(this).ids(result.getNodeIds()).build().execute();
    for (final Node child : children) {
        setNodeStateWithChildren(child, setNodeStateResultBuilder);
    }
    return updatedNode;
}
Also used : Node(com.enonic.xp.node.Node) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) Nodes(com.enonic.xp.node.Nodes)

Example 18 with Nodes

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

the class NodeStorageServiceImpl method doReturnNodes.

private Nodes doReturnNodes(final NodeBranchEntries nodeBranchEntries, final InternalContext context) {
    final NodeVersionKeys.Builder builder = NodeVersionKeys.create();
    nodeBranchEntries.stream().map(NodeBranchEntry::getNodeVersionKey).forEach(builder::add);
    final NodeVersions nodeVersions = nodeVersionService.get(builder.build(), context);
    final Nodes.Builder filteredNodes = Nodes.create();
    nodeVersions.stream().filter((nodeVersion) -> canRead(nodeVersion.getPermissions())).forEach((nodeVersion) -> filteredNodes.add(NodeFactory.create(nodeVersion, nodeBranchEntries.get(nodeVersion.getId()))));
    return filteredNodes.build();
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) BlobKeys(com.enonic.xp.blob.BlobKeys) NodePaths(com.enonic.xp.node.NodePaths) Nodes(com.enonic.xp.node.Nodes) RoutableNodeVersionIds(com.enonic.xp.node.RoutableNodeVersionIds) Node(com.enonic.xp.node.Node) VersionService(com.enonic.xp.repo.impl.version.VersionService) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) BlobKey(com.enonic.xp.blob.BlobKey) Branch(com.enonic.xp.branch.Branch) Permission(com.enonic.xp.security.acl.Permission) NodeCommitId(com.enonic.xp.node.NodeCommitId) Component(org.osgi.service.component.annotations.Component) BranchService(com.enonic.xp.repo.impl.branch.BranchService) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeVersionId(com.enonic.xp.node.NodeVersionId) NodeVersionKeys(com.enonic.xp.blob.NodeVersionKeys) PushNodeEntries(com.enonic.xp.node.PushNodeEntries) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodePath(com.enonic.xp.node.NodePath) NodeVersions(com.enonic.xp.node.NodeVersions) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AccessControlList(com.enonic.xp.security.acl.AccessControlList) AttachedBinary(com.enonic.xp.node.AttachedBinary) NodeId(com.enonic.xp.node.NodeId) PushNodeEntry(com.enonic.xp.node.PushNodeEntry) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) NodeVersionService(com.enonic.xp.repo.impl.node.dao.NodeVersionService) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersion(com.enonic.xp.node.NodeVersion) RoleKeys(com.enonic.xp.security.RoleKeys) CommitService(com.enonic.xp.repo.impl.commit.CommitService) Reference(org.osgi.service.component.annotations.Reference) NodeIds(com.enonic.xp.node.NodeIds) NodeFactory(com.enonic.xp.repo.impl.branch.storage.NodeFactory) PushNodesListener(com.enonic.xp.node.PushNodesListener) NodeVersionKeys(com.enonic.xp.blob.NodeVersionKeys) Nodes(com.enonic.xp.node.Nodes) NodeVersions(com.enonic.xp.node.NodeVersions)

Example 19 with Nodes

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

the class NodeEventsTest method testStateUpdated.

@Test
public void testStateUpdated() {
    final Node pushed1 = createNode("state_updated1", NodePath.create("/mynode1/state_updated1").build(), "id1");
    final Node pushed2 = createNode("state_updated2", NodePath.create("/mynode1/state_updated2").build(), "id2");
    final Node pushed3 = createNode("state_updated3", NodePath.create("/mynode1/state_updated3").build(), "id3");
    final Nodes nodes = Nodes.from(pushed1, pushed2, pushed3);
    Event event = NodeEvents.stateUpdated(nodes);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertTrue(event.hasValue("nodes"));
    assertTrue(event.hasValue("state"));
    assertEquals(NodeEvents.NODE_STATE_UPDATED_EVENT, event.getType());
    assertEquals(NodeState.DEFAULT.toString(), event.getValue("state").get());
    assertEquals("[{id=id1, path=/mynode1/state_updated1/state_updated1, branch=draft, repo=com.enonic.cms.default}" + ", {id=id2, path=/mynode1/state_updated2/state_updated2, branch=draft, repo=com.enonic.cms.default}" + ", {id=id3, path=/mynode1/state_updated3/state_updated3, branch=draft, repo=com.enonic.cms.default}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) Nodes(com.enonic.xp.node.Nodes) Test(org.junit.jupiter.api.Test)

Example 20 with Nodes

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

the class IndexServiceImplTest method queryForNode.

private Node queryForNode(final NodeId nodeId) {
    final FindNodesByQueryResult result = FindNodesByQueryCommand.create().indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).query(NodeQuery.create().query(QueryParser.parse("_id = '" + nodeId.toString() + "'")).build()).build().execute();
    final Nodes nodes = getNodes(result.getNodeIds());
    return nodes.getNodeById(nodeId);
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Nodes(com.enonic.xp.node.Nodes)

Aggregations

Nodes (com.enonic.xp.node.Nodes)31 Node (com.enonic.xp.node.Node)14 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)9 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)9 Test (org.junit.jupiter.api.Test)8 NodeQuery (com.enonic.xp.node.NodeQuery)5 Contents (com.enonic.xp.content.Contents)4 NodeIds (com.enonic.xp.node.NodeIds)3 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)3 CompareExpr (com.enonic.xp.query.expr.CompareExpr)3 QueryExpr (com.enonic.xp.query.expr.QueryExpr)3 Branch (com.enonic.xp.branch.Branch)2 Content (com.enonic.xp.content.Content)2 FindNodesByParentParams (com.enonic.xp.node.FindNodesByParentParams)2 NodePaths (com.enonic.xp.node.NodePaths)2 Principals (com.enonic.xp.security.Principals)2 AccessControlList (com.enonic.xp.security.acl.AccessControlList)2 Application (com.enonic.xp.app.Application)1 ApplicationKey (com.enonic.xp.app.ApplicationKey)1 BlobKey (com.enonic.xp.blob.BlobKey)1