Search in sources :

Example 11 with NodeBranchEntry

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

the class ReindexExecutor method doReindexBranchNew.

private void doReindexBranchNew(final RepositoryId repositoryId, final ReindexResult.Builder builder, final Branch branch) {
    final NodeBranchEntries nodeBranchEntries = GetBranchDataCommand.create().branch(branch).repositoryId(repositoryId).nodeSearchService(this.nodeSearchService).build().execute();
    if (listener != null) {
        listener.branch(repositoryId, branch, nodeBranchEntries.getSize());
    }
    for (final NodeBranchEntry nodeBranchEntry : nodeBranchEntries) {
        final InternalContext context = InternalContext.create(ContextAccessor.current()).repositoryId(repositoryId).branch(branch).build();
        final NodeVersion nodeVersion = this.nodeVersionService.get(nodeBranchEntry.getNodeVersionKey(), context);
        final Node node = NodeFactory.create(nodeVersion, nodeBranchEntry);
        this.indexDataService.store(node, context);
        builder.add(node.id());
        if (listener != null) {
            listener.branchEntry(nodeBranchEntry);
        }
    }
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeVersion(com.enonic.xp.node.NodeVersion) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 12 with NodeBranchEntry

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

the class AbstractCompareNodeCommand method doCompareNodeVersions.

NodeComparison doCompareNodeVersions(final Context context, final NodeId nodeId) {
    final NodeBranchEntry sourceWsVersion = nodeStorageService.getBranchNodeVersion(nodeId, InternalContext.from(context));
    final NodeBranchEntry targetWsVersion = nodeStorageService.getBranchNodeVersion(nodeId, InternalContext.create(context).branch(this.target).build());
    final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceWsVersion).target(targetWsVersion).storageService(this.nodeStorageService).build().resolve();
    return new NodeComparison(sourceWsVersion, targetWsVersion, compareStatus);
}
Also used : NodeComparison(com.enonic.xp.node.NodeComparison) CompareStatus(com.enonic.xp.content.CompareStatus) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 13 with NodeBranchEntry

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

the class NodeEventListenerTest method node_delete_event.

@Test
public void node_delete_event() throws Exception {
    final NodeId nodeId = NodeId.from("node1");
    final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
    final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(nodeId).nodePath(nodePath).nodeState(NodeState.DEFAULT).build();
    final Event localEvent = NodeEvents.deleted(NodeBranchEntries.create().add(nodeBranchEntry).build());
    nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
    Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodeDeleted(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.isA(InternalContext.class));
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeId(com.enonic.xp.node.NodeId) Event(com.enonic.xp.event.Event) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 14 with NodeBranchEntry

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

the class NodeEventListenerTest method node_pushed_event.

@Test
public void node_pushed_event() throws Exception {
    final NodeId nodeId = NodeId.from("node1");
    final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
    final NodePath previousNodePath = NodePath.create(NodePath.ROOT, "previousName").build();
    final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(nodeId).nodePath(nodePath).nodeState(NodeState.DEFAULT).build();
    final PushNodeEntry pushNodeEntry = PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry).currentTargetPath(previousNodePath).build();
    final PushNodeEntries pushNodeEntries = PushNodeEntries.create().targetRepo(ContentConstants.CONTENT_REPO_ID).targetBranch(ContentConstants.BRANCH_MASTER).add(pushNodeEntry).build();
    final Event localEvent = NodeEvents.pushed(pushNodeEntries);
    nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
    Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodePushed(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.eq(previousNodePath), Mockito.isA(InternalContext.class));
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeId(com.enonic.xp.node.NodeId) Event(com.enonic.xp.event.Event) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) PushNodeEntries(com.enonic.xp.node.PushNodeEntries) NodePath(com.enonic.xp.node.NodePath) PushNodeEntry(com.enonic.xp.node.PushNodeEntry) Test(org.junit.jupiter.api.Test)

Example 15 with NodeBranchEntry

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

the class BranchServiceImpl method delete.

@Override
public void delete(final NodeId nodeId, final InternalContext context) {
    final NodeBranchEntry nodeBranchEntry = doGetById(nodeId, context);
    if (nodeBranchEntry == null) {
        return;
    }
    storageDao.delete(BranchDeleteRequestFactory.create(nodeId, context));
    pathCache.evict(createPath(nodeBranchEntry.getNodePath(), context));
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

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