Search in sources :

Example 66 with Node

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();
}
Also used : Node(com.enonic.xp.node.Node) ChildOrder(com.enonic.xp.index.ChildOrder) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult) NodePath(com.enonic.xp.node.NodePath)

Example 67 with Node

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();
}
Also used : Node(com.enonic.xp.node.Node)

Example 68 with Node

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();
}
Also used : Node(com.enonic.xp.node.Node)

Example 69 with Node

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();
}
Also used : Node(com.enonic.xp.node.Node) CreateRootNodeParams(com.enonic.xp.node.CreateRootNodeParams)

Example 70 with Node

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();
    }
}
Also used : Node(com.enonic.xp.node.Node)

Aggregations

Node (com.enonic.xp.node.Node)521 Test (org.junit.jupiter.api.Test)371 PropertyTree (com.enonic.xp.data.PropertyTree)114 NodeId (com.enonic.xp.node.NodeId)52 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)51 NodePath (com.enonic.xp.node.NodePath)45 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)42 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)34 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)32 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)29 NodeQuery (com.enonic.xp.node.NodeQuery)27 AccessControlList (com.enonic.xp.security.acl.AccessControlList)27 BinaryReference (com.enonic.xp.util.BinaryReference)26 ByteSource (com.google.common.io.ByteSource)24 Content (com.enonic.xp.content.Content)23 PropertySet (com.enonic.xp.data.PropertySet)20 NodeIds (com.enonic.xp.node.NodeIds)18 Context (com.enonic.xp.context.Context)17 InternalContext (com.enonic.xp.repo.impl.InternalContext)17 Application (com.enonic.xp.app.Application)16