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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations