use of com.enonic.xp.export.ExportError 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.ExportError in project xp by enonic.
the class NodeExporter method execute.
public NodeExportResult execute() {
this.result.dryRun(this.dryRun);
final Node rootNode = this.nodeService.getByPath(this.sourceNodePath);
if (rootNode != null) {
if (nodeExportListener != null) {
final long childNodeCount = getRecursiveNodeCountByParentPath(sourceNodePath);
nodeExportListener.nodeResolved(childNodeCount + 1);
}
try {
exportNode(rootNode);
} catch (Exception e) {
LOG.error(String.format("Failed to export node with path [%s]", rootNode.path()), e);
result.addError(new ExportError(e.toString()));
}
} else {
addRootNodeNotFoundError();
}
writeExportProperties();
return result.build();
}
use of com.enonic.xp.export.ExportError in project xp by enonic.
the class NodeExporter method doExport.
private FindNodesByParentResult doExport(final NodePath nodePath) {
final FindNodesByParentResult children = nodeService.findByParent(FindNodesByParentParams.create().parentPath(nodePath).build());
final Nodes childNodes = this.nodeService.getByIds(children.getNodeIds());
for (final Node child : childNodes) {
try {
exportNode(child);
} catch (Exception e) {
LOG.error(String.format("Failed to export node with path [%s]", child.path()), e);
result.addError(new ExportError(e.toString()));
}
}
return children;
}
Aggregations