Search in sources :

Example 6 with FileExportWriter

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();
}
Also used : Path(java.nio.file.Path) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter)

Example 7 with FileExportWriter

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");
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 8 with FileExportWriter

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");
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) Node(com.enonic.xp.node.Node) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

FileExportWriter (com.enonic.xp.core.impl.export.writer.FileExportWriter)8 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)7 Test (org.junit.jupiter.api.Test)7 NodeExportResult (com.enonic.xp.export.NodeExportResult)6 Node (com.enonic.xp.node.Node)4 PropertyTree (com.enonic.xp.data.PropertyTree)1 NodeExportListener (com.enonic.xp.export.NodeExportListener)1 BinaryReference (com.enonic.xp.util.BinaryReference)1 Path (java.nio.file.Path)1 Disabled (org.junit.jupiter.api.Disabled)1