Search in sources :

Example 6 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 7 with NodeBranchEntries

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

the class RepositoryEntryServiceImpl method deleteRepositoryEntry.

@Override
public void deleteRepositoryEntry(final RepositoryId repositoryId) {
    final NodeBranchEntries deletedNodes = createContext().callWith(() -> DeleteNodeByIdCommand.create().nodeId(NodeId.from(repositoryId.toString())).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).build().execute());
    if (deletedNodes.isNotEmpty()) {
        eventPublisher.publish(NodeEvents.deleted(deletedNodes));
        refresh();
        eventPublisher.publish(RepositoryEvents.deleted(repositoryId));
    }
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries)

Example 8 with NodeBranchEntries

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

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

the class CompareNodesCommand method execute.

public NodeComparisons execute() {
    Set<NodeId> allNodeIds = new HashSet<>();
    final Context context = ContextAccessor.current();
    final NodeComparisons.Builder builder = NodeComparisons.create();
    final NodeBranchEntries sourceVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.from(context));
    final NodeBranchEntries targetVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.create(context).branch(this.target).build());
    allNodeIds.addAll(sourceVersions.getKeys());
    allNodeIds.addAll(targetVersions.getKeys());
    for (final NodeId id : allNodeIds) {
        final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceVersions.get(id)).target(targetVersions.get(id)).storageService(this.nodeStorageService).build().resolve();
        builder.add(new NodeComparison(sourceVersions.get(id), targetVersions.get(id), compareStatus));
    }
    return builder.build();
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeComparison(com.enonic.xp.node.NodeComparison) NodeId(com.enonic.xp.node.NodeId) CompareStatus(com.enonic.xp.content.CompareStatus) NodeComparisons(com.enonic.xp.node.NodeComparisons) HashSet(java.util.HashSet)

Example 10 with NodeBranchEntries

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

the class NodeServiceImpl method deleteByPath.

@Override
public NodeIds deleteByPath(final NodePath path) {
    verifyContext();
    final NodeBranchEntries deletedNodes = DeleteNodeByPathCommand.create().nodePath(path).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).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