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