Search in sources :

Example 1 with NodeVersions

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());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) NodeVersions(com.enonic.xp.node.NodeVersions) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 2 with NodeVersions

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

Aggregations

Node (com.enonic.xp.node.Node)2 NodeVersions (com.enonic.xp.node.NodeVersions)2 BlobKey (com.enonic.xp.blob.BlobKey)1 BlobKeys (com.enonic.xp.blob.BlobKeys)1 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)1 NodeVersionKeys (com.enonic.xp.blob.NodeVersionKeys)1 Branch (com.enonic.xp.branch.Branch)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 AttachedBinaries (com.enonic.xp.node.AttachedBinaries)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)1 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)1 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)1 NodeCommitId (com.enonic.xp.node.NodeCommitId)1 NodeId (com.enonic.xp.node.NodeId)1 NodeIds (com.enonic.xp.node.NodeIds)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 NodePath (com.enonic.xp.node.NodePath)1