use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class ExportServiceImpl method exportNodes.
@Override
public NodeExportResult exportNodes(final ExportNodesParams params) {
final Path targetDirectory = Optional.ofNullable(params.getTargetDirectory()).map(Path::of).orElseGet(() -> exportsDir.resolve(params.getExportName()));
final Path rootDirectory = Optional.ofNullable(params.getRootDirectory()).map(Path::of).orElse(targetDirectory);
return NodeExporter.create().sourceNodePath(params.getSourceNodePath()).nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).rootDirectory(rootDirectory).targetDirectory(targetDirectory).xpVersion(xpVersion).dryRun(params.isDryRun()).exportNodeIds(params.isIncludeNodeIds()).exportVersions(params.isIncludeVersions()).nodeExportListener(params.getNodeExportListener()).build().execute();
}
use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method one_node_file.
@Test
public void one_node_file() throws Exception {
createNode("mynode", NodePath.ROOT);
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(2, result.size());
assertFileExists("myExport/_/node.xml");
assertFileExists("myExport/mynode/_/node.xml");
}
use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method writerOrderList.
@Test
public void writerOrderList() {
final Node root = Node.create().name(NodeName.from("root")).parentPath(NodePath.ROOT).childOrder(ChildOrder.manualOrder()).build();
this.nodeService.create(CreateNodeParams.from(root).build());
createNode("child1", root.path());
createNode("child2", root.path());
createNode("child3", root.path());
createNode("child4", root.path());
createNode("child5", root.path());
createNode("child6", root.path());
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(8, result.size());
assertFileExists("myExport/root/_/node.xml");
assertFileExists("myExport/root/_/manualChildOrder.txt");
}
Aggregations