Search in sources :

Example 1 with NodePath

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

the class MoveNodeHandler method moveAndRename.

private Node moveAndRename(final Node node) {
    final NodePath targetPath = target.getAsNodePath();
    final NodePath targetParent = targetPath.getParentPath();
    final boolean movedToNewParent = !targetParent.equals(node.parentPath());
    if (movedToNewParent) {
        // First rename the node to a temporary unique name to avoid clashing with siblings with target name in source parent or with siblings with source name in target parent
        rename(node.id(), uniqueName());
        move(node.id(), targetParent);
    }
    return rename(node.id(), NodeName.from(targetPath.getName()));
}
Also used : NodePath(com.enonic.xp.node.NodePath)

Example 2 with NodePath

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

the class NodeImportResultJson method from.

public static NodeImportResultJson from(final NodeImportResult result) {
    final NodeImportResultJson json = new NodeImportResultJson();
    json.dryRun = result.isDryRun();
    for (final NodePath nodePath : result.getAddedNodes()) {
        json.addedNodes.add(nodePath.toString());
    }
    for (final NodePath nodePath : result.getUpdateNodes()) {
        json.updateNodes.add(nodePath.toString());
    }
    for (final NodeImportResult.ImportError importError : result.getImportErrors()) {
        json.importErrors.add(importError.getMessage() + " - " + importError.getException());
    }
    json.importedBinaries.addAll(result.getImportedBinaries());
    return json;
}
Also used : NodePath(com.enonic.xp.node.NodePath) NodeImportResult(com.enonic.xp.export.NodeImportResult)

Example 3 with NodePath

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

the class FindContentByParentCommand method setNodePathOrIdAsIdentifier.

private void setNodePathOrIdAsIdentifier(final FindNodesByParentParams.Builder findNodesParam) {
    if (params.getParentPath() == null && params.getParentId() == null) {
        final NodePath parentPath = ContentNodeHelper.getContentRoot();
        findNodesParam.parentPath(parentPath);
    } else if (params.getParentPath() != null) {
        final NodePath parentPath = ContentNodeHelper.translateContentPathToNodePath(params.getParentPath());
        findNodesParam.parentPath(parentPath);
    } else {
        final NodeId parentId = NodeId.from(params.getParentId().toString());
        findNodesParam.parentId(parentId);
    }
}
Also used : NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath)

Example 4 with NodePath

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

the class FindContentIdsByParentCommand method setNodePathOrIdAsIdentifier.

private void setNodePathOrIdAsIdentifier(final FindNodesByParentParams.Builder findNodesParam) {
    if (params.getParentPath() == null && params.getParentId() == null) {
        final NodePath parentPath = ContentNodeHelper.getContentRoot();
        findNodesParam.parentPath(parentPath);
    } else if (params.getParentPath() != null) {
        final NodePath parentPath = ContentNodeHelper.translateContentPathToNodePath(params.getParentPath());
        findNodesParam.parentPath(parentPath);
    } else {
        final NodeId parentId = NodeId.from(params.getParentId().toString());
        findNodesParam.parentId(parentId);
    }
}
Also used : NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath)

Example 5 with NodePath

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

the class GetContentByPathAndVersionIdCommand method execute.

public Content execute() {
    final NodePath nodePath = ContentNodeHelper.translateContentPathToNodePath(contentPath);
    final NodeVersionId nodeVersionId = NodeVersionId.from(contentVersionId.toString());
    try {
        final Node node = nodeService.getByPathAndVersionId(nodePath, nodeVersionId);
        final Content content = filter(translator.fromNode(node, true));
        if (content != null) {
            return content;
        }
        throw createContentNotFoundException();
    } catch (NodeNotFoundException e) {
        throw createContentNotFoundException();
    }
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeVersionId(com.enonic.xp.node.NodeVersionId) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) NodePath(com.enonic.xp.node.NodePath)

Aggregations

NodePath (com.enonic.xp.node.NodePath)54 Node (com.enonic.xp.node.Node)27 Test (org.junit.jupiter.api.Test)20 NodeId (com.enonic.xp.node.NodeId)15 InternalContext (com.enonic.xp.repo.impl.InternalContext)12 Content (com.enonic.xp.content.Content)7 Event (com.enonic.xp.event.Event)7 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)4 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 ChildOrder (com.enonic.xp.index.ChildOrder)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 ContentId (com.enonic.xp.content.ContentId)2 ContentPath (com.enonic.xp.content.ContentPath)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 Context (com.enonic.xp.context.Context)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 MoveNodeParams (com.enonic.xp.node.MoveNodeParams)2 NodeVersion (com.enonic.xp.node.NodeVersion)2