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