Search in sources :

Example 1 with VirtualFilePath

use of com.enonic.xp.vfs.VirtualFilePath in project xp by enonic.

the class NodeImportPathResolver method resolveNodeImportPath.

public static NodePath resolveNodeImportPath(final VirtualFile parent, final VirtualFile exportRoot, final NodePath importRoot) {
    final VirtualFilePath parentPath = parent.getPath();
    final VirtualFilePath exportRootPath = exportRoot.getPath();
    final VirtualFilePath relativePath = parentPath.subtractPath(exportRootPath);
    final NodePath.Builder builder = NodePath.create(importRoot);
    relativePath.getElements().forEach(builder::addElement);
    return builder.build();
}
Also used : VirtualFilePath(com.enonic.xp.vfs.VirtualFilePath) NodePath(com.enonic.xp.node.NodePath)

Example 2 with VirtualFilePath

use of com.enonic.xp.vfs.VirtualFilePath in project xp by enonic.

the class NodeImporter method getChildrenAbsolutePaths.

private List<String> getChildrenAbsolutePaths(final VirtualFile parent, final List<String> childNames) {
    final List<String> children = new ArrayList<>();
    for (final String childName : childNames) {
        final VirtualFilePath join = parent.getPath().join(childName);
        children.add(join.getPath());
    }
    return children;
}
Also used : VirtualFilePath(com.enonic.xp.vfs.VirtualFilePath) ArrayList(java.util.ArrayList)

Example 3 with VirtualFilePath

use of com.enonic.xp.vfs.VirtualFilePath in project xp by enonic.

the class ExportReader method getOrderSource.

public VirtualFile getOrderSource(final VirtualFile nodeFolder) {
    final VirtualFilePath orderSourcePath = nodeFolder.getPath().join(SYSTEM_FOLDER_NAME, ORDER_EXPORT_NAME);
    final VirtualFile orderFile = nodeFolder.resolve(orderSourcePath);
    if (!orderFile.exists()) {
        throw new ImportNodeException("Parent has manual ordering of children, expected at:" + orderFile.getPath());
    }
    return orderFile;
}
Also used : VirtualFile(com.enonic.xp.vfs.VirtualFile) VirtualFilePath(com.enonic.xp.vfs.VirtualFilePath) ImportNodeException(com.enonic.xp.export.ImportNodeException)

Example 4 with VirtualFilePath

use of com.enonic.xp.vfs.VirtualFilePath in project xp by enonic.

the class ExportReader method getBinarySource.

public VirtualFile getBinarySource(final VirtualFile nodeFolder, final String binaryReferenceString) {
    final VirtualFilePath binaryFilePath = nodeFolder.getPath().join(SYSTEM_FOLDER_NAME, BINARY_FOLDER, binaryReferenceString);
    final VirtualFile binaryFile = nodeFolder.resolve(binaryFilePath);
    if (!binaryFile.exists()) {
        throw new ImportNodeException("Missing binary source, expected at: " + binaryFile.getPath());
    }
    return binaryFile;
}
Also used : VirtualFile(com.enonic.xp.vfs.VirtualFile) VirtualFilePath(com.enonic.xp.vfs.VirtualFilePath) ImportNodeException(com.enonic.xp.export.ImportNodeException)

Example 5 with VirtualFilePath

use of com.enonic.xp.vfs.VirtualFilePath in project xp by enonic.

the class ExportReader method getNodeSource.

public VirtualFile getNodeSource(final VirtualFile nodeFolder) {
    final VirtualFilePath nodeSourcePath = nodeFolder.getPath().join(SYSTEM_FOLDER_NAME, NODE_XML_EXPORT_NAME);
    final VirtualFile nodeVF = nodeFolder.resolve(nodeSourcePath);
    if (!nodeVF.exists()) {
        throw new ImportNodeException("Missing node source, expected at: " + nodeVF.getPath());
    }
    return nodeVF;
}
Also used : VirtualFile(com.enonic.xp.vfs.VirtualFile) VirtualFilePath(com.enonic.xp.vfs.VirtualFilePath) ImportNodeException(com.enonic.xp.export.ImportNodeException)

Aggregations

VirtualFilePath (com.enonic.xp.vfs.VirtualFilePath)5 ImportNodeException (com.enonic.xp.export.ImportNodeException)3 VirtualFile (com.enonic.xp.vfs.VirtualFile)3 NodePath (com.enonic.xp.node.NodePath)1 ArrayList (java.util.ArrayList)1