use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class ExportHandler method execute.
public NodeExportResultMapper execute() {
final ExportNodesParams.Builder paramsBuilder = ExportNodesParams.create().sourceNodePath(NodePath.create(sourceNodePath).build()).exportName(exportName).nodeExportListener(new FunctionBasedNodeExportListener(nodeExported, nodeResolved));
if (includeNodeIds != null) {
paramsBuilder.includeNodeIds(includeNodeIds);
}
if (includeVersions != null) {
paramsBuilder.includeVersions(includeVersions);
}
final NodeExportResult nodeImportResult = this.context.getService(ExportService.class).get().exportNodes(paramsBuilder.build());
return new NodeExportResultMapper(nodeImportResult);
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class ExportRunnableTask method run.
@Override
public void run(final TaskId id, final ProgressReporter progressReporter) {
final NodeExportResult result = getContext(params.getSourceRepoPath()).callWith(() -> this.exportService.exportNodes(ExportNodesParams.create().sourceNodePath(params.getSourceRepoPath().getNodePath()).exportName(params.getExportName()).dryRun(params.isDryRun()).includeNodeIds(params.isExportWithIds()).includeVersions(params.isIncludeVersions()).nodeExportListener(new ExportListenerImpl(progressReporter)).build()));
progressReporter.info(NodeExportResultJson.from(result).toString());
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class ExportHandlerTest method testExample.
@Test
public void testExample() {
final NodeExportResult result = NodeExportResult.create().addNodePath(NodePath.create("/content").build()).addBinary(NodePath.create("binaryPath").build(), BinaryReference.from("ref")).addError(new ExportError("some error")).build();
when(exportService.exportNodes(any())).thenReturn(result);
runScript("/lib/xp/examples/export/exportNodes.js");
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class ExportRunnableTaskTest method exportNodes.
@Test
public void exportNodes() {
final NodeExportResult nodeExportResult = NodeExportResult.create().addNodePath(NodePath.create().addElement("node").addElement("path").build()).addBinary(NodePath.create().elements("binary").build(), BinaryReference.from("binaryRef")).build();
Mockito.when(this.exportService.exportNodes(isA(ExportNodesParams.class))).thenReturn(nodeExportResult);
final ExportRunnableTask task = createAndRunTask(new ExportNodesRequestJson("a:b:c", "export", true, true, true));
task.createTaskResult();
Mockito.verify(progressReporter, Mockito.times(1)).info(contentQueryArgumentCaptor.capture());
Mockito.verify(taskService, Mockito.times(1)).submitTask(Mockito.isA(RunnableTask.class), Mockito.eq("export"));
final String result = contentQueryArgumentCaptor.getAllValues().get(0);
jsonTestHelper.assertJsonEquals(jsonTestHelper.loadTestJson("exportNodes_result.json"), jsonTestHelper.stringToJson(result));
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class NodeExportIntegrationTest method include_export_root_and_nested_children.
@Test
public void include_export_root_and_nested_children() throws Exception {
final Node root = createNode("mynode", NodePath.ROOT);
final Node child1 = createNode("child1", root.path());
createNode("child2", root.path());
final Node child1_1 = createNode("child1_1", child1.path());
createNode("child1_1_1", child1_1.path());
createNode("child1_1_2", child1_1.path());
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.create("/mynode/child1").build()).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(4, result.getExportedNodes().getSize());
assertFileExists("myExport/child1/_/node.xml");
assertFileExists("myExport/child1/child1_1/_/node.xml");
assertFileExists("myExport/child1/child1_1/child1_1_1/_/node.xml");
assertFileExists("myExport/child1/child1_1/child1_1_2/_/node.xml");
}
Aggregations