use of com.enonic.xp.node.NodeVersions in project xp by enonic.
the class NodeVersionServiceImplTest method getVersions.
@Test
public void getVersions() throws Exception {
final CreateNodeParams createNodeParams = CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).build();
final PropertyTree data = new PropertyTree();
data.addString("myName", "myValue");
final CreateNodeParams createNodeParams2 = CreateNodeParams.create().name("my-node2").parent(NodePath.ROOT).data(data).build();
final Node createdNode = createNode(createNodeParams);
final Node createdNode2 = createNode(createNodeParams2);
final NodeVersions nodeVersions = nodeDao.get(NodeVersionKeys.from(getNodeVersionKey(createdNode), getNodeVersionKey(createdNode2)), createInternalContext());
assertEquals(2, nodeVersions.getSize());
assertEquals(createdNode.id(), nodeVersions.get(0).getId());
assertEquals(createdNode.data(), nodeVersions.get(0).getData());
assertEquals(createdNode2.id(), nodeVersions.get(1).getId());
assertEquals(createdNode2.data(), nodeVersions.get(1).getData());
}
use of com.enonic.xp.node.NodeVersions 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();
}
Aggregations