use of org.apache.commons.vfs2.provider.local.LocalFileSystem in project georchestra by georchestra.
the class UploadPackage method unpack.
public void unpack(@NonNull String archiveRelativeFileName) throws IOException {
log.info("Unpacking {}", archiveRelativeFileName);
Path archive = resolve(archiveRelativeFileName);
if (!Files.exists(archive)) {
throw new FileNotFoundException(archiveRelativeFileName + " not found under " + id);
}
FileSystemManager fsManager = VFS.getManager();
try (FileObject fsRoot = fsManager.resolveFile(archive.toUri())) {
try (FileObject localFileSystem = fsManager.createFileSystem(fsRoot)) {
FileObject[] children = localFileSystem.getChildren();
unpack(children);
}
}
}
use of org.apache.commons.vfs2.provider.local.LocalFileSystem in project scheduling by ow2-proactive.
the class DataSpaceServiceStarter method createSpaceWithUserNameSubfolder.
/**
* Similar to createSpace, but in addition it will use a provided username to append it to the given urls
* If the localpath is provided, it will also create sub folders to the dataspace root with this username
*
* @param username username used to update urls and create folders
* @param userCredentials credentials of the user
* @param appID the Application ID
* @param spaceName the name of the dataspace
* @param urls the url list of the Virtual File Systems (for different protocols)
* @param localpath the path to the dataspace in the localfilesystem
* @param hostname the host where the file server is deployed
* @param inputConfiguration if the configuration is an InputSpace configuration (read-only)
* @param localConfiguration if the local node needs to be configured for the provided application
* @throws URISyntaxException
* @throws MalformedURLException
* @throws ProActiveException
* @throws FileSystemException
*/
public void createSpaceWithUserNameSubfolder(String username, UserCredentials userCredentials, String appID, String spaceName, String urls, String localpath, String hostname, boolean inputConfiguration, boolean localConfiguration) throws URISyntaxException, IOException, ProActiveException {
// updates the urls with the username
String[] urlsArray = Tools.dataSpaceConfigPropertyToUrls(urls);
if (localpath != null) {
DefaultFileSystemManager manager = VFSFactory.createDefaultFileSystemManager(userCredentials);
try {
FileObject folder = manager.resolveFile(urlsArray[0] + "/" + username);
folder.createFolder();
} finally {
manager.close();
}
}
String[] updatedArray = urlsWithUserDir(urlsArray, username);
String newPropertyValue = urlsToDSConfigProperty(updatedArray);
// create the User Space for the given user
createSpace(appID, spaceName, newPropertyValue, localpath, hostname, inputConfiguration, localConfiguration);
}
use of org.apache.commons.vfs2.provider.local.LocalFileSystem in project commons-vfs by apache.
the class TemporaryFileProvider method findFile.
/**
* Locates a file object, by absolute URI.
*
* @param baseFile The base FileObject.
* @param uri The URI of the file to be located.
* @param fileSystemOptions FileSystemOptions to use to locate or create the file.
* @return The FileObject.
* @throws FileSystemException if an error occurs.
*/
@Override
public synchronized FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions) throws FileSystemException {
// Parse the name
final StringBuilder buffer = new StringBuilder(uri);
final String scheme = UriParser.extractScheme(getContext().getFileSystemManager().getSchemes(), uri, buffer);
UriParser.fixSeparators(buffer);
UriParser.normalisePath(buffer);
final String path = buffer.toString();
// Create the temp file system if it does not exist
// FileSystem filesystem = findFileSystem( this, (Properties) null);
FileSystem filesystem = findFileSystem(this, fileSystemOptions);
if (filesystem == null) {
if (rootFile == null) {
rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs");
}
final FileName rootName = getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
// final FileName rootName =
// new LocalFileName(scheme, scheme + ":", FileName.ROOT_PATH);
filesystem = new LocalFileSystem(rootName, rootFile.getAbsolutePath(), fileSystemOptions);
addFileSystem(this, filesystem);
}
// Find the file
return filesystem.resolveFile(path);
}
use of org.apache.commons.vfs2.provider.local.LocalFileSystem in project pivot by apache.
the class TerraVFSBrowserSheetSkin method setHostLabel.
private void setHostLabel(FileObject rootDir) {
try {
if (rootDir != null) {
hostNameBoxPane.setVisible(true);
FileSystem localFileSystem = rootDir.getFileSystem();
if (!localFileSystem.equals(fileSystem)) {
fileSystem = localFileSystem;
FileObject root = fileSystem.getRoot();
String rootURL = root.getURL().toString();
// Parse out the host name with some special considerations
Matcher m = HOST_PATTERN.matcher(rootURL);
if (m.matches()) {
hostNameLabel.setText(m.group(1));
} else {
hostNameLabel.setText(rootURL);
}
}
} else {
hostNameBoxPane.setVisible(false);
}
} catch (FileSystemException ex) {
throw new RuntimeException(ex);
}
}
Aggregations