Search in sources :

Example 1 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext 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 InternalContext

use of com.enonic.xp.repo.impl.InternalContext 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 InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class CheckNodeExistsCommand method execute.

public boolean execute() {
    final InternalContext context = InternalContext.create(ContextAccessor.current()).searchPreference(Mode.ACCURACY.equals(mode) ? SearchPreference.PRIMARY : SearchPreference.LOCAL).build();
    if (Mode.ACCURACY.equals(mode)) {
        RefreshCommand.create().indexServiceInternal(this.indexServiceInternal).refreshMode(RefreshMode.STORAGE).build().execute();
    }
    final NodeId found = nodeStorageService.getIdForPath(nodePath, context);
    if (found != null && throwIfExists) {
        throw new NodeAlreadyExistAtPathException(nodePath, context.getRepositoryId(), context.getBranch());
    }
    return found != null;
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeId(com.enonic.xp.node.NodeId) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException)

Example 4 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class AbstractNodeEventHandler method createNodeContext.

InternalContext createNodeContext(final Map<Object, Object> map, final InternalContext context) {
    final InternalContext.Builder nodeContext = InternalContext.create(context);
    final RepositoryId repositoryId = getRepositoryId(map);
    if (repositoryId != null) {
        nodeContext.repositoryId(repositoryId);
    }
    final Branch branch = getBranch(map);
    if (branch != null) {
        nodeContext.branch(branch);
    }
    return nodeContext.build();
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Branch(com.enonic.xp.branch.Branch) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 5 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class NodeDeletedHandler method handleEvent.

@Override
public void handleEvent(final NodeStorageService nodeStorageService, final Event event, final InternalContext context) {
    final List<Map<Object, Object>> valueMapList = getValueMapList(event);
    for (final Map<Object, Object> map : valueMapList) {
        final InternalContext nodeContext = createNodeContext(map, context);
        nodeStorageService.handleNodeDeleted(getId(map), getPath(map), nodeContext);
    }
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Map(java.util.Map)

Aggregations

InternalContext (com.enonic.xp.repo.impl.InternalContext)18 Node (com.enonic.xp.node.Node)6 Context (com.enonic.xp.context.Context)5 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)5 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)5 NodePath (com.enonic.xp.node.NodePath)5 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)4 NodeId (com.enonic.xp.node.NodeId)4 Map (java.util.Map)4 Branch (com.enonic.xp.branch.Branch)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodePaths (com.enonic.xp.node.NodePaths)3 NodeVersion (com.enonic.xp.node.NodeVersion)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)2 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeCommitId (com.enonic.xp.node.NodeCommitId)2 NodeComparison (com.enonic.xp.node.NodeComparison)2 NodeVersionId (com.enonic.xp.node.NodeVersionId)2