Search in sources :

Example 1 with NodeBranchEntries

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());
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) NodePaths(com.enonic.xp.node.NodePaths) StoreStorageName(com.enonic.xp.repo.impl.storage.StoreStorageName) SearchRequest(com.enonic.xp.repo.impl.search.SearchRequest) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) ValueFilter(com.enonic.xp.query.filter.ValueFilter) Supplier(java.util.function.Supplier) StorageDao(com.enonic.xp.repo.impl.storage.StorageDao) BranchPath(com.enonic.xp.repo.impl.cache.BranchPath) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult) Component(org.osgi.service.component.annotations.Component) BranchService(com.enonic.xp.repo.impl.branch.BranchService) BranchCachePath(com.enonic.xp.repo.impl.cache.BranchCachePath) SingleRepoStorageSource(com.enonic.xp.repo.impl.SingleRepoStorageSource) SearchDao(com.enonic.xp.repo.impl.search.SearchDao) IdFilter(com.enonic.xp.query.filter.IdFilter) ReturnFields(com.enonic.xp.repo.impl.ReturnFields) Striped(com.google.common.util.concurrent.Striped) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) StaticStorageType(com.enonic.xp.repo.impl.storage.StaticStorageType) InternalContext(com.enonic.xp.repo.impl.InternalContext) StoreRequest(com.enonic.xp.repo.impl.storage.StoreRequest) NodePath(com.enonic.xp.node.NodePath) NodeBranchQueryResult(com.enonic.xp.repo.impl.branch.search.NodeBranchQueryResult) ValueFactory(com.enonic.xp.data.ValueFactory) GetResult(com.enonic.xp.repo.impl.storage.GetResult) Collectors(java.util.stream.Collectors) NodeId(com.enonic.xp.node.NodeId) Objects(java.util.Objects) List(java.util.List) Lock(java.util.concurrent.locks.Lock) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) StorageSource(com.enonic.xp.repo.impl.StorageSource) NodeBranchQueryResultFactory(com.enonic.xp.repo.impl.branch.search.NodeBranchQueryResultFactory) Reference(org.osgi.service.component.annotations.Reference) NodeIds(com.enonic.xp.node.NodeIds) GetByIdRequest(com.enonic.xp.repo.impl.storage.GetByIdRequest) DeleteRequests(com.enonic.xp.repo.impl.storage.DeleteRequests) NodeBranchQuery(com.enonic.xp.repo.impl.branch.search.NodeBranchQuery)

Example 2 with NodeBranchEntries

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);
        }
    }
}
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 3 with NodeBranchEntries

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;
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeAccessException(com.enonic.xp.node.NodeAccessException) NodeIds(com.enonic.xp.node.NodeIds) NodeId(com.enonic.xp.node.NodeId) OperationNotPermittedException(com.enonic.xp.node.OperationNotPermittedException)

Example 4 with NodeBranchEntries

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();
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) ExcludeEntry(com.enonic.xp.repo.impl.version.search.ExcludeEntry) ExcludeEntries(com.enonic.xp.repo.impl.version.search.ExcludeEntries) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 5 with NodeBranchEntries

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());
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries)

Aggregations

NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)16 Node (com.enonic.xp.node.Node)7 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)7 InternalContext (com.enonic.xp.repo.impl.InternalContext)7 NodeId (com.enonic.xp.node.NodeId)5 Context (com.enonic.xp.context.Context)4 NodeIds (com.enonic.xp.node.NodeIds)4 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)3 NodeComparison (com.enonic.xp.node.NodeComparison)3 NodeComparisons (com.enonic.xp.node.NodeComparisons)3 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)3 NodePath (com.enonic.xp.node.NodePath)3 NodePaths (com.enonic.xp.node.NodePaths)3 NodeVersion (com.enonic.xp.node.NodeVersion)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 Branch (com.enonic.xp.branch.Branch)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeCommitId (com.enonic.xp.node.NodeCommitId)2 NodeVersionId (com.enonic.xp.node.NodeVersionId)2