Search in sources :

Example 31 with NodePath

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

the class ContentNodeHelperTest method translateContentParentToNodeParentPath.

@Test
public void translateContentParentToNodeParentPath() {
    final NodePath nodePath = ContentNodeHelper.translateContentParentToNodeParentPath(ContentPath.from("/site/myContent"));
    assertEquals(NodePath.create("/content/site/myContent").build(), nodePath);
}
Also used : NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 32 with NodePath

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

the class NodeExporter method writeVersion.

private void writeVersion(final Node node, final Path baseFolder) {
    final NodePath newParentPath = resolveNewParentPath(node);
    final Node relativeNode = Node.create(node).parentPath(newParentPath).build();
    final XmlNodeSerializer serializer = new XmlNodeSerializer();
    serializer.exportNodeIds(this.exportNodeIds);
    serializer.node(relativeNode);
    final String serializedNode = serializer.serialize();
    if (!dryRun) {
        final Path nodeXmlPath = baseFolder.resolve(NodeExportPathResolver.NODE_XML_EXPORT_NAME);
        exportWriter.writeElement(nodeXmlPath, serializedNode);
    }
    exportNodeBinaries(relativeNode, baseFolder);
}
Also used : NodePath(com.enonic.xp.node.NodePath) Path(java.nio.file.Path) Node(com.enonic.xp.node.Node) XmlNodeSerializer(com.enonic.xp.core.impl.export.xml.XmlNodeSerializer) NodePath(com.enonic.xp.node.NodePath)

Example 33 with NodePath

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

the class NodeImportPathResolverTest method resolve_into_root.

@Test
public void resolve_into_root() throws Exception {
    final NodePath resolvedPath = // 
    NodeImportPathResolver.resolveNodeImportPath(// 
    VirtualFiles.from(Path.of("/var", "folder", "myExport", "mynode")), // 
    VirtualFiles.from(Path.of("/var", "folder", "myExport")), NodePath.ROOT);
    assertEquals("/mynode", resolvedPath.toString());
}
Also used : NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 34 with NodePath

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

the class ResolveSyncWorkCommand method getParentIdsFromPaths.

private NodeIds getParentIdsFromPaths(final NodePaths parentPaths) {
    final NodeIds.Builder parentIdBuilder = NodeIds.create();
    for (final NodePath parent : parentPaths) {
        final NodeId parentId = this.nodeStorageService.getIdForPath(parent, InternalContext.from(ContextAccessor.current()));
        if (parentId == null) {
            throw new NodeNotFoundException("Cannot find parent with path [" + parent + "]");
        }
        parentIdBuilder.add(parentId);
    }
    return parentIdBuilder.build();
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeIds(com.enonic.xp.node.NodeIds) NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath)

Example 35 with NodePath

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

the class NodePushedHandler method handleEvent.

@Override
public void handleEvent(NodeStorageService storageService, final Event event, final InternalContext context) {
    final List<Map<Object, Object>> valueMapList = getValueMapList(event);
    for (final Map<Object, Object> map : valueMapList) {
        final InternalContext nodeContext = createNodeContext(map, context);
        final NodePath currentTargetPath = map.containsKey(CURRENT_TARGET_PATH) ? NodePath.create(map.get(CURRENT_TARGET_PATH).toString()).build() : null;
        storageService.handleNodePushed(getId(map), getPath(map), currentTargetPath, nodeContext);
    }
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Map(java.util.Map) 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