Search in sources :

Example 16 with org.apache.commons.vfs2

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

the class VFSFileSystem method listFolders.

@Override
public String[] listFolders(String folderPath) throws FileSystemException {
    try {
        final FileObject fo = resolveFileObject(folderPath);
        final List<String> entries = new LinkedList<>();
        for (FileObject child : fo.getChildren()) {
            if (child.isFolder()) {
                entries.add(child.getName().getBaseName());
            }
        }
        return entries.toArray(new String[entries.size()]);
    } catch (org.apache.commons.vfs2.FileSystemException e) {
        final String msg = "Failed to list child folders of the folder at " + folderPath + ".";
        log.debug(msg);
        throw new FileSystemException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileObject(org.apache.commons.vfs2.FileObject) LinkedList(java.util.LinkedList)

Example 17 with org.apache.commons.vfs2

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

the class VFSFileSystem method deleteFile.

@Override
public void deleteFile(String filePath) throws FileSystemException {
    try {
        final FileObject fo = resolveFileObject(filePath);
        if (!fo.isFile()) {
            throw new FileSystemException("File doesn't exist at " + filePath + ".");
        }
        fo.delete();
    } catch (org.apache.commons.vfs2.FileSystemException e) {
        final String msg = "Failed to delete file at " + filePath;
        log.debug(msg, e);
        throw new FileSystemException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileObject(org.apache.commons.vfs2.FileObject)

Example 18 with org.apache.commons.vfs2

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

the class VFSFileSystem method getOutputStream.

@Override
public OutputStream getOutputStream(String filePath) throws FileSystemException {
    try {
        final FileObject fo = resolveFileObject(filePath);
        final FileObject folder = fo.getParent();
        if (!folder.exists() || !folder.isFolder()) {
            throw new FileSystemException("Folder doesn't exist for " + filePath + ".");
        }
        return fo.getContent().getOutputStream();
    } catch (org.apache.commons.vfs2.FileSystemException e) {
        final String msg = "Failed to open an output stream to " + filePath + ".";
        log.debug(msg, e);
        throw new FileSystemException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileObject(org.apache.commons.vfs2.FileObject)

Example 19 with org.apache.commons.vfs2

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

the class VFSFileSystem method createFolder.

@Override
public void createFolder(String folderPath) throws FileSystemException {
    try {
        final FileObject fo = resolveFileObject(folderPath);
        if (fo.isFolder()) {
            log.debug("Folder already exists at {}.", fo.getName().getFriendlyURI());
            throw new FileSystemException("Folder already exists at " + folderPath + ".");
        }
        fo.createFolder();
    } catch (org.apache.commons.vfs2.FileSystemException e) {
        final String msg = "Failed to create folder at " + folderPath + ".";
        log.debug(msg, e);
        throw new FileSystemException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileObject(org.apache.commons.vfs2.FileObject)

Example 20 with org.apache.commons.vfs2

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

the class VFSFileSystem method listFiles.

@Override
public String[] listFiles(String folderPath) throws FileSystemException {
    try {
        final FileObject fo = resolveFileObject(folderPath);
        final List<String> entries = new LinkedList<>();
        for (FileObject child : fo.getChildren()) {
            if (child.isFile()) {
                entries.add(child.getName().getBaseName());
            }
        }
        return entries.toArray(new String[entries.size()]);
    } catch (org.apache.commons.vfs2.FileSystemException e) {
        final String msg = "Failed to list child files of the folder at " + folderPath + ".";
        log.debug(msg, e);
        throw new FileSystemException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileObject(org.apache.commons.vfs2.FileObject) LinkedList(java.util.LinkedList)

Aggregations

FileObject (org.apache.commons.vfs2.FileObject)13 FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)11 FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)6 FileSystemException (org.apache.commons.vfs2.FileSystemException)5 IOException (java.io.IOException)4 UserAuthenticationData (org.apache.commons.vfs2.UserAuthenticationData)4 SoftRefFilesCache (org.apache.commons.vfs2.cache.SoftRefFilesCache)4 DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)4 FileContentInfoFilenameFactory (org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory)4 GenericFileName (org.apache.commons.vfs2.provider.GenericFileName)4 JSchException (com.jcraft.jsch.JSchException)3 File (java.io.File)3 HdfsFileProvider (org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider)3 ChannelExec (com.jcraft.jsch.ChannelExec)2 InputStreamReader (java.io.InputStreamReader)2 LinkedList (java.util.LinkedList)2 DefaultFileReplicator (org.apache.commons.vfs2.impl.DefaultFileReplicator)2 AbstractFileObject (org.apache.commons.vfs2.provider.AbstractFileObject)2 HttpClient (org.apache.http.client.HttpClient)2 HttpClientContext (org.apache.http.client.protocol.HttpClientContext)2