use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class BranchServiceImpl method delete.
@Override
public void delete(final NodeIds nodeIds, final InternalContext context) {
final NodeBranchEntries nodeBranchEntries = getIgnoreOrder(nodeIds, context);
nodeBranchEntries.forEach(entry -> pathCache.evict(createPath(entry.getNodePath(), context)));
storageDao.delete(DeleteRequests.create().forceRefresh(false).ids(nodeIds.stream().map(nodeId -> new BranchDocumentId(nodeId, context.getBranch()).toString()).collect(Collectors.toList())).settings(createStorageSettings(context)).build());
}
use of com.enonic.xp.node.NodeBranchEntries 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.NodeBranchEntries in project xp by enonic.
the class AbstractDeleteNodeCommand method deleteNodeWithChildren.
NodeBranchEntries deleteNodeWithChildren(final Node node, final Context context, final DeleteNodeListener deleteNodeListener) {
if (node.isRoot() && !allowDeleteRootNode) {
throw new OperationNotPermittedException("Not allowed to delete root-node");
}
doRefresh();
final NodeBranchEntries nodesToBeDeleted = newResolveNodesToDelete(node);
final NodeIds nodeIds = NodeIds.from(nodesToBeDeleted.getKeys());
final boolean allHasPermissions = NodesHasPermissionResolver.create(this).nodeIds(nodeIds).permission(Permission.DELETE).build().execute();
if (!allHasPermissions) {
throw new NodeAccessException(context.getAuthInfo().getUser(), node.path(), Permission.DELETE);
}
for (final List<NodeId> keysBatch : Iterables.partition(nodeIds, BATCH_SIZE)) {
this.nodeStorageService.delete(NodeIds.from(keysBatch), InternalContext.from(context));
if (deleteNodeListener != null) {
deleteNodeListener.nodesDeleted(keysBatch.size());
}
}
doRefresh();
return nodesToBeDeleted;
}
use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class FindNodesWithVersionDifferenceCommand method getExcludePaths.
private ExcludeEntries getExcludePaths(final InternalContext context) {
if (this.excludes.isEmpty()) {
return ExcludeEntries.empty();
}
final ExcludeEntries.Builder builder = ExcludeEntries.create();
final NodeBranchEntries result = this.nodeStorageService.getBranchNodeVersions(excludes, false, context);
for (final NodeBranchEntry entry : result) {
builder.add(new ExcludeEntry(entry.getNodePath(), false));
}
return builder.build();
}
use of com.enonic.xp.node.NodeBranchEntries in project xp by enonic.
the class NodeServiceImpl method deleteById.
@Override
public NodeIds deleteById(final NodeId id, final DeleteNodeListener deleteNodeListener) {
verifyContext();
final NodeBranchEntries deletedNodes = DeleteNodeByIdCommand.create().nodeId(id).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).deleteNodeListener(deleteNodeListener).build().execute();
if (deletedNodes.isNotEmpty()) {
this.eventPublisher.publish(NodeEvents.deleted(deletedNodes));
}
return NodeIds.from(deletedNodes.getKeys());
}
Aggregations