Search in sources :

Example 16 with NodeBranchEntry

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

the class GetBranchEntriesMethod method execute.

@Override
public void execute(final Collection<NodeId> nodeIds, final NodeBranchEntries.Builder builder) {
    final GetByIdsRequest getByIdsRequest = new GetByIdsRequest();
    for (final NodeId nodeId : nodeIds) {
        getByIdsRequest.add(GetByIdRequest.create().id(new BranchDocumentId(nodeId, context.getBranch()).toString()).storageSettings(StorageSource.create().storageName(StoreStorageName.from(context.getRepositoryId())).storageType(StaticStorageType.BRANCH).build()).returnFields(returnFields).routing(nodeId.toString()).build());
    }
    final GetResults getResults = this.storageDao.getByIds(getByIdsRequest);
    for (final GetResult getResult : getResults) {
        if (!getResult.isEmpty()) {
            final NodeBranchEntry nodeBranchEntry = NodeBranchVersionFactory.create(getResult.getReturnValues());
            builder.add(nodeBranchEntry);
        }
    }
}
Also used : GetResult(com.enonic.xp.repo.impl.storage.GetResult) NodeId(com.enonic.xp.node.NodeId) GetResults(com.enonic.xp.repo.impl.storage.GetResults) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) GetByIdsRequest(com.enonic.xp.repo.impl.storage.GetByIdsRequest)

Example 17 with NodeBranchEntry

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

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

the class NodeStorageServiceImpl method move.

@Override
public Node move(final StoreMovedNodeParams params, final InternalContext context) {
    final NodeBranchEntry nodeBranchEntry = this.branchService.get(params.getNode().id(), context);
    final NodeVersionKey nodeVersionKey = nodeVersionService.store(NodeVersion.from(params.getNode()), context);
    NodeVersionId nodeVersionId = params.getNodeVersionId();
    if (nodeVersionId == null) {
        nodeVersionId = new NodeVersionId();
        storeVersionMetadata(params.getNode(), nodeVersionId, nodeVersionKey, context);
    }
    return moveInBranchAndReIndex(params.getNode(), nodeVersionId, nodeVersionKey, nodeBranchEntry.getNodePath(), context);
}
Also used : NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 19 with NodeBranchEntry

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

the class NodeStorageServiceImpl method push.

@Override
public void push(final PushNodeEntries entries, final PushNodesListener pushListener, final InternalContext context) {
    for (final PushNodeEntry entry : entries) {
        final NodeBranchEntry nodeBranchEntry = entry.getNodeBranchEntry();
        this.branchService.store(nodeBranchEntry, entry.getCurrentTargetPath(), InternalContext.create(context).branch(entries.getTargetBranch()).build());
        if (pushListener != null) {
            pushListener.nodesPushed(1);
        }
    }
    this.indexDataService.push(IndexPushNodeParams.create().nodeIds(entries.getNodeIds()).targetBranch(entries.getTargetBranch()).targetRepo(entries.getTargetRepo()).pushListener(pushListener).build(), context);
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) PushNodeEntry(com.enonic.xp.node.PushNodeEntry)

Example 20 with NodeBranchEntry

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

the class NodeStorageServiceImplTest method testGetNode_ByPath.

@Test
public void testGetNode_ByPath() {
    final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(nodeId).nodePath(nodePath).nodeState(NodeState.DEFAULT).build();
    final NodeVersionMetadata nodeVersionMetadata = NodeVersionMetadata.create().nodeVersionId(nodeVersionId).nodeVersionKey(versionKey).nodePath(nodePath).build();
    final NodeVersion nodeVersion = NodeVersion.create().permissions(AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()).build()).build();
    when(branchService.get(any(NodePath.class), any(InternalContext.class))).thenReturn(nodeBranchEntry);
    when(versionService.getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class))).thenReturn(nodeVersionMetadata);
    when(nodeVersionService.get(any(NodeVersionKey.class), any(InternalContext.class))).thenReturn(nodeVersion);
    final Node result = instance.getNode(nodePath, nodeVersionId, context);
    assertNotNull(result);
    verify(branchService, times(1)).get(any(NodePath.class), any(InternalContext.class));
    verify(versionService, times(1)).getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class));
    verify(nodeVersionService, times(1)).get(any(NodeVersionKey.class), any(InternalContext.class));
    verifyNoMoreInteractions(branchService, versionService, nodeVersionService);
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeVersionId(com.enonic.xp.node.NodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Aggregations

NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)25 InternalContext (com.enonic.xp.repo.impl.InternalContext)9 Test (org.junit.jupiter.api.Test)8 Node (com.enonic.xp.node.Node)7 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)6 NodeId (com.enonic.xp.node.NodeId)5 NodePath (com.enonic.xp.node.NodePath)5 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)4 NodeVersion (com.enonic.xp.node.NodeVersion)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 PushNodeEntries (com.enonic.xp.node.PushNodeEntries)4 RoutableNodeVersionId (com.enonic.xp.node.RoutableNodeVersionId)4 Event (com.enonic.xp.event.Event)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3 PushNodeEntry (com.enonic.xp.node.PushNodeEntry)3 Branch (com.enonic.xp.branch.Branch)2 Context (com.enonic.xp.context.Context)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeComparison (com.enonic.xp.node.NodeComparison)2 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)2