Search in sources :

Example 1 with FileName

use of org.apache.commons.vfs2.FileName in project jackrabbit by apache.

the class VFSDataStore method init.

@Override
public void init(String homeDir) throws RepositoryException {
    overridePropertiesFromConfig();
    if (baseFolderUri == null) {
        throw new RepositoryException("VFS base folder URI must be set.");
    }
    fileSystemManager = createFileSystemManager();
    FileName baseFolderName = null;
    try {
        baseFolderName = fileSystemManager.resolveURI(baseFolderUri);
        FileSystemOptions fso = getFileSystemOptions();
        if (fso != null) {
            baseFolder = fileSystemManager.resolveFile(baseFolderUri, fso);
        } else {
            baseFolder = fileSystemManager.resolveFile(baseFolderUri);
        }
        baseFolder.createFolder();
    } catch (FileSystemException e) {
        throw new RepositoryException("Could not initialize the VFS base folder at '" + (baseFolderName == null ? "" : baseFolderName.getFriendlyURI()) + "'.", e);
    }
    super.init(homeDir);
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) FileName(org.apache.commons.vfs2.FileName) RepositoryException(javax.jcr.RepositoryException) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

Example 2 with FileName

use of org.apache.commons.vfs2.FileName in project zeppelin by apache.

the class VFSNotebookRepo method list.

@Override
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
    FileObject rootDir = getRootDir();
    FileObject[] children = rootDir.getChildren();
    List<NoteInfo> infos = new LinkedList<>();
    for (FileObject f : children) {
        String fileName = f.getName().getBaseName();
        if (f.isHidden() || fileName.startsWith(".") || fileName.startsWith("#") || fileName.startsWith("~")) {
            // skip hidden, temporary files
            continue;
        }
        if (!isDirectory(f)) {
            // so it must be a directory
            continue;
        }
        NoteInfo info = null;
        try {
            info = getNoteInfo(f);
            if (info != null) {
                infos.add(info);
            }
        } catch (Exception e) {
            LOG.error("Can't read note " + f.getName().toString(), e);
        }
    }
    return infos;
}
Also used : NoteInfo(org.apache.zeppelin.notebook.NoteInfo) FileObject(org.apache.commons.vfs2.FileObject) LinkedList(java.util.LinkedList) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 LinkedList (java.util.LinkedList)1 RepositoryException (javax.jcr.RepositoryException)1 FileName (org.apache.commons.vfs2.FileName)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)1 NoteInfo (org.apache.zeppelin.notebook.NoteInfo)1