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