Search in sources :

Example 86 with NodeId

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

the class GetActiveVersionHandler method execute.

@Override
public Object execute() {
    final NodeId nodeId = getNodeId(key);
    if (nodeId == null) {
        return null;
    }
    final Branch branch = ContextAccessor.current().getBranch();
    final GetActiveNodeVersionsParams params = GetActiveNodeVersionsParams.create().nodeId(nodeId).branches(Branches.from(branch)).build();
    final NodeVersionMetadata nodeVersionMetadata = nodeService.getActiveVersions(params).getNodeVersions().get(branch);
    if (nodeVersionMetadata == null) {
        return null;
    }
    return new NodeVersionMapper(nodeVersionMetadata);
}
Also used : Branch(com.enonic.xp.branch.Branch) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeId(com.enonic.xp.node.NodeId) GetActiveNodeVersionsParams(com.enonic.xp.node.GetActiveNodeVersionsParams)

Example 87 with NodeId

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

the class CreateNodeParamsFactory method setName.

private void setName(final String name, final CreateNodeParams.Builder builder) {
    if (isNullOrEmpty(name)) {
        final NodeId nodeId = new NodeId();
        builder.setNodeId(nodeId);
        builder.name(nodeId.toString());
    } else {
        builder.name(name);
    }
}
Also used : NodeId(com.enonic.xp.node.NodeId)

Example 88 with NodeId

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

the class FindVersionsHandler method execute.

@Override
public Object execute() {
    final NodeVersionQueryResult result;
    NodeId nodeId = getNodeId(key);
    if (nodeId == null) {
        result = NodeVersionQueryResult.empty(0);
    } else {
        GetNodeVersionsParams params = GetNodeVersionsParams.create().nodeId(nodeId).from(from).size(size).build();
        result = nodeService.findVersions(params);
    }
    return new NodeVersionsQueryResultMapper(result);
}
Also used : NodeId(com.enonic.xp.node.NodeId) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) GetNodeVersionsParams(com.enonic.xp.node.GetNodeVersionsParams)

Example 89 with NodeId

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

the class PushNodeHandler method doResolve.

private void doResolve(final NodeIds nodeIds, final NodeIds.Builder toBePushed, final NodeIds.Builder toBeDeleted) {
    for (final NodeId nodeId : nodeIds) {
        final ResolveSyncWorkResult result = this.nodeService.resolveSyncWork(SyncWorkResolverParams.create().nodeId(nodeId).branch(targetBranch).excludedNodeIds(getNodeIds(exclude)).includeChildren(includeChildren).build());
        result.getNodeComparisons().forEach(nodeComparison -> {
            if (nodeComparison.getCompareStatus().equals(CompareStatus.PENDING_DELETE)) {
                toBeDeleted.add(nodeComparison.getNodeId());
            } else {
                toBePushed.add(nodeComparison.getNodeId());
            }
        });
    }
}
Also used : NodeId(com.enonic.xp.node.NodeId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Example 90 with NodeId

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

the class FindNodesByParentResultMapper method serialize.

private void serialize(final MapGenerator gen, final NodeIds nodeIds) {
    gen.array("hits");
    for (NodeId nodeId : nodeIds) {
        gen.map();
        gen.value("id", nodeId);
        gen.end();
    }
    gen.end();
}
Also used : NodeId(com.enonic.xp.node.NodeId)

Aggregations

NodeId (com.enonic.xp.node.NodeId)91 Node (com.enonic.xp.node.Node)44 Test (org.junit.jupiter.api.Test)36 NodePath (com.enonic.xp.node.NodePath)23 InternalContext (com.enonic.xp.repo.impl.InternalContext)18 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)15 NodeIds (com.enonic.xp.node.NodeIds)14 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)11 Context (com.enonic.xp.context.Context)10 PropertyTree (com.enonic.xp.data.PropertyTree)10 Branch (com.enonic.xp.branch.Branch)9 ContextAccessor (com.enonic.xp.context.ContextAccessor)9 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)9 NodeVersionId (com.enonic.xp.node.NodeVersionId)9 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)8 RefreshMode (com.enonic.xp.node.RefreshMode)8 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)8 ContextBuilder (com.enonic.xp.context.ContextBuilder)6 Event (com.enonic.xp.event.Event)6 RenameNodeParams (com.enonic.xp.node.RenameNodeParams)6