use of com.enonic.xp.node.Node in project xp by enonic.
the class FindNodesByParentCommand method execute.
public FindNodesByParentResult execute() {
NodePath parentPath = params.getParentPath();
if (parentPath == null) {
Node parent = GetNodeByIdCommand.create(this).id(params.getParentId()).build().execute();
if (parent == null) {
return FindNodesByParentResult.empty();
}
parentPath = parent.path();
}
final ChildOrder order = NodeChildOrderResolver.create(this).nodePath(parentPath).childOrder(params.getChildOrder()).build().resolve();
final SearchResult result = this.nodeSearchService.query(NodeQuery.create().parent(parentPath).addQueryFilters(params.getQueryFilters()).from(params.getFrom()).size(params.getSize()).searchMode(params.isCountOnly() ? SearchMode.COUNT : SearchMode.SEARCH).setOrderExpressions(order.getOrderExpressions()).accurateScoring(true).build(), SingleRepoSearchSource.from(ContextAccessor.current()));
if (result.isEmpty()) {
return FindNodesByParentResult.create().hits(0).totalHits(result.getTotalHits()).nodeIds(NodeIds.empty()).build();
}
return FindNodesByParentResult.create().nodeIds(NodeIds.from(result.getIds())).totalHits(result.getTotalHits()).hits(result.getNumberOfHits()).build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class ImportNodeCommand method execute.
public ImportNodeResult execute() {
final boolean exists = CheckNodeExistsCommand.create(this).nodePath(this.importNode.path()).mode(CheckNodeExistsCommand.Mode.SPEED).build().execute();
final Node node;
if (!exists) {
node = createNode();
} else {
node = updateNode(GetNodeByPathCommand.create(this).nodePath(this.importNode.path()).build().execute());
}
return ImportNodeResult.create().node(node).preExisting(exists).build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class LoadNodeCommand method loadNode.
private LoadNodeResult loadNode() {
verifyParentExists();
deleteIfExistsAtPath();
final com.enonic.xp.repo.impl.storage.LoadNodeParams loadNodeParams = com.enonic.xp.repo.impl.storage.LoadNodeParams.create().node(params.getNode()).nodeCommitId(params.getNodeCommitId()).build();
final Node loadedNode = this.nodeStorageService.load(loadNodeParams, InternalContext.from(ContextAccessor.current()));
return LoadNodeResult.create().node(loadedNode).build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class LoadNodeCommand method loadRootNode.
private LoadNodeResult loadRootNode() {
final CreateRootNodeParams createRootNodeParams = CreateRootNodeParams.create().permissions(params.getNode().getPermissions()).childOrder(params.getNode().getChildOrder()).build();
final Node node = CreateRootNodeCommand.create(this).params(createRootNodeParams).build().execute();
return LoadNodeResult.create().node(node).build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class LoadNodeCommand method execute.
public LoadNodeResult execute() {
verifyNodeProperties(params.getNode());
final Node nodeToLoad = params.getNode();
if (nodeToLoad.path().isRoot()) {
return loadRootNode();
} else {
return loadNode();
}
}
Aggregations