use of org.apache.commons.vfs2.FileSystemManager in project pivot by apache.
the class TerraVFSBrowserSkin method rootDirectoryChanged.
@Override
public void rootDirectoryChanged(VFSBrowser fileBrowser, FileObject previousRootDirectory) {
ArrayList<FileObject> path = new ArrayList<>();
// FileSystemManager manager = fileBrowser.getManager();
FileObject rootDirectory = fileBrowser.getRootDirectory();
try {
FileObject ancestorDirectory = rootDirectory.getParent();
while (ancestorDirectory != null) {
path.add(ancestorDirectory);
ancestorDirectory = ancestorDirectory.getParent();
}
} catch (FileSystemException fse) {
throw new RuntimeException(fse);
}
@SuppressWarnings("unchecked") ArrayList<FileObject> drives = (ArrayList<FileObject>) driveListButton.getListData();
if (refreshRoots) {
// TODO: this is ugly -- need to do much better at managing drive
// list with VFS
// There is an open question on the Dev list about adding
// "getFileRoots()" to the VFS API.
/*
* try { FileObject[] roots = new FileObject[1]; roots[0] =
* manager.resolveFile
* (manager.getBaseFile().getName().getRoot().getURI()); drives =
* new ArrayList<>(); for (int i = 0; i < roots.length; i++) {
* FileObject root = roots[i]; if (root.exists()) {
* drives.add(root); } } driveListButton.setListData(drives); }
* catch (FileSystemException fse) { throw new
* RuntimeException(fse); }
*/
refreshRoots = false;
}
driveListButton.setVisible(drives.getLength() > 1);
FileObject drive;
if (path.getLength() == 0) {
drive = rootDirectory;
} else {
drive = path.get(path.getLength() - 1);
}
driveListButton.setSelectedItem(drive);
pathListButton.setListData(path);
pathListButton.setButtonData(rootDirectory);
pathListButton.setEnabled(rootDirectory.getName().getDepth() > 0);
goUpButton.setEnabled(pathListButton.isEnabled());
goHomeButton.setEnabled(!rootDirectory.equals(homeDirectory));
fileScrollPane.setScrollTop(0);
fileScrollPane.setScrollLeft(0);
searchTextInput.setText("");
fileTableView.requestFocus();
}
use of org.apache.commons.vfs2.FileSystemManager in project jackrabbit by apache.
the class VFSDataStore method createFileSystemManager.
/**
* Creates a {@link FileSystemManager} instance.
* @return a {@link FileSystemManager} instance.
* @throws RepositoryException if an error occurs creating the manager.
*/
protected FileSystemManager createFileSystemManager() throws RepositoryException {
FileSystemManager fileSystemManager = null;
try {
if (getFileSystemManagerClassName() == null) {
fileSystemManager = new StandardFileSystemManager();
} else {
final Class<?> mgrClass = Class.forName(getFileSystemManagerClassName());
fileSystemManager = (FileSystemManager) mgrClass.newInstance();
}
if (fileSystemManager instanceof DefaultFileSystemManager) {
((DefaultFileSystemManager) fileSystemManager).init();
}
} catch (final FileSystemException e) {
throw new RepositoryException("Could not initialize file system manager of class: " + getFileSystemManagerClassName(), e);
} catch (final Exception e) {
throw new RepositoryException("Could not create file system manager of class: " + getFileSystemManagerClassName(), e);
}
return fileSystemManager;
}
use of org.apache.commons.vfs2.FileSystemManager 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);
}
use of org.apache.commons.vfs2.FileSystemManager in project metron by apache.
the class VFSClassloaderUtil method configureClassloader.
/**
* Create a classloader backed by a virtual filesystem which can handle the following URI types:
* * res - resource files
* * jar
* * tar
* * bz2
* * tgz
* * zip
* * HDFS
* * FTP
* * HTTP/S
* * file
* @param paths A set of comma separated paths. The paths are URIs or URIs with a regex pattern at the end.
* @return A classloader object if it can create it
* @throws FileSystemException
*/
public static Optional<ClassLoader> configureClassloader(String paths) throws FileSystemException {
LOG.debug("Configuring class loader with paths = {}", paths);
if (paths.trim().isEmpty()) {
LOG.debug("No paths provided. Not returning a ClassLoader.");
return Optional.empty();
}
FileSystemManager vfs = generateVfs();
FileObject[] objects = resolve(vfs, paths);
if (objects == null || objects.length == 0) {
LOG.debug("No Classloader able to be resolved from provided paths. Not returning a ClassLoader.");
return Optional.empty();
}
LOG.debug("vfs = {}, objects = {}", vfs, objects);
return Optional.of(new VFSClassLoader(objects, vfs, vfs.getClass().getClassLoader()));
}
use of org.apache.commons.vfs2.FileSystemManager in project scheduling by ow2-proactive.
the class VFSZipperZIPTest method testUnzipEmptyContent.
@Test
public void testUnzipEmptyContent() throws IOException, InterruptedException {
Files.createFile(archivePath);
FileSystemManager fsManager = VFS.getManager();
VFSZipper.ZIP.unzip(Files.newInputStream(archivePath), fsManager.resolveFile(outputPath.toUri()));
assertThat(outputPath.toFile().listFiles()).isNull();
}
Aggregations