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);
}
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);
}
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());
}
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();
}
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);
}
}
Aggregations