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