Search in sources :

Example 76 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class NodeServiceImpl method getByPath.

@Override
public Node getByPath(final NodePath path) {
    final Trace trace = Tracer.newTrace("node.getByPath");
    if (trace == null) {
        return executeGetByPath(path);
    }
    return Tracer.trace(trace, () -> {
        trace.put("path", path);
        final Node node = executeGetByPath(path);
        if (node != null) {
            trace.put("id", node.id());
        }
        return node;
    });
}
Also used : Trace(com.enonic.xp.trace.Trace) Node(com.enonic.xp.node.Node)

Example 77 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class NodeServiceImpl method getByIdAndVersionId.

@Override
public Node getByIdAndVersionId(final NodeId id, final NodeVersionId versionId) {
    final Trace trace = Tracer.newTrace("node.getByIdAndVersionId");
    if (trace == null) {
        return executeGetByIdAndVersionId(id, versionId);
    }
    return Tracer.trace(trace, () -> {
        trace.put("id", id);
        trace.put("versionId", versionId);
        final Node node = executeGetByIdAndVersionId(id, versionId);
        trace.put("path", node.path());
        return node;
    });
}
Also used : Trace(com.enonic.xp.trace.Trace) Node(com.enonic.xp.node.Node)

Example 78 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class NodeServiceImpl method getRoot.

@Override
public Node getRoot() {
    verifyContext();
    final Node node = doGetByPath(NodePath.ROOT);
    if (node == null || node.isRoot()) {
        return node;
    }
    throw new RuntimeException("Expected node with path " + NodePath.ROOT + " to be of type RootNode, found " + node.id());
}
Also used : Node(com.enonic.xp.node.Node)

Example 79 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class ReorderChildNodeCommand method resolveInsertInbetweenOrderValue.

private Long resolveInsertInbetweenOrderValue(final Long nodeAfterOrderValue, final SearchResult result) {
    final NodeId nodeBeforeInsertId = NodeId.from(result.getHits().getFirst().getId());
    final Node nodeBeforeInsert = doGetById(nodeBeforeInsertId);
    return (nodeAfterOrderValue + nodeBeforeInsert.getManualOrderValue()) / 2;
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId)

Example 80 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class ReorderChildNodeCommand method resolveInsertLastOrderValue.

private Long resolveInsertLastOrderValue(final SearchResult result) {
    final NodeId lastNodeId = NodeId.from(result.getHits().getFirst().getId());
    final Node lastNode = doGetById(lastNodeId);
    if (lastNode.getManualOrderValue() == null) {
        throw new IllegalArgumentException("Node with id [" + lastNode.id() + "] missing manual order value");
    }
    return lastNode.getManualOrderValue() - NodeManualOrderValueResolver.ORDER_SPACE;
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId)

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