/** * Constructor * * @param root */ public SFTPRepository(String root) { try { this.root = this.fsManager.resolveFile(root); } catch (FileSystemException e) { e.printStackTrace(); } }
/** * Extracts the archive file {@code archiveFile} to {@code targetFolder}; both shall previously * exist. */ public void extractTo(File archiveFile, File targetFolder) throws IOException { FileSystemManager manager = VFS.getManager(); String sourceURI = resolveArchiveURI(archiveFile); // String targetURI = resolveArchiveURI(targetFolder); FileObject source = manager.resolveFile(sourceURI); if (manager.canCreateFileSystem(source)) { source = manager.createFileSystem(source); } FileObject target = manager.createVirtualFileSystem(manager.resolveFile(targetFolder .getAbsolutePath())); FileSelector selector = new AllFileSelector() { @Override public boolean includeFile(FileSelectInfo fileInfo) { LOGGER.fine("Uncompressing " + fileInfo.getFile().getName().getFriendlyURI()); return true; } }; target.copyFrom(source, selector); source.close(); manager.closeFileSystem(source.getFileSystem()); }
/** * Removes a junction from this file system. */ public void removeJunction(final String junctionPoint) throws FileSystemException { final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint); junctions.remove(junctionName); // TODO - remove from parents of junction point // TODO - detach all cached children of the junction point from their real file }
public FileObject createVirtualFileSystem(final String rootUri) throws FileSystemException { assert rootUri != null; FileObject file = getManager().resolveFile(rootUri); return getManager().createVirtualFileSystem(file); }
/** * Appends the specified FileObjects to the list of FileObjects to search * for classes and resources. * * @param files the FileObjects to append to the search path. */ private void addFileObjects(final FileSystemManager manager, final FileObject[] files) throws FileSystemException { for (int i = 0; i < files.length; i++) { FileObject file = files[i]; if (!file.exists()) { // Does not exist - skip continue; } // TODO - use federation instead if (manager.canCreateFileSystem(file)) { // Use contents of the file file = manager.createFileSystem(file); } resources.add(file); } }
protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject to = VFS.getManager().resolveFile(url.toExternalForm()); File tmpFile = File.createTempFile("xxFilexx", ".json"); FileUtils.writeStringToFile(tmpFile, json); FileObject from = VFS.getManager().toFileObject(tmpFile); to.copyFrom(from, new AllFileSelector()); FileUtils.deleteQuietly(tmpFile); } else { FileUtils.writeStringToFile(FileUtils.toFile(url), json); } }
/** * Constructor * * @param rootFileUrl */ public WebDAVRepository(String rootFileUrl) { try { this.setFsManager(VFS.getManager()); this.root = this.fsManager.resolveFile(rootFileUrl); this.fsManager.createFileSystem(root); } catch (FileSystemException e) { e.printStackTrace(); } }
fsManager = VFS.getManager(); String absolutePath = resolveArchiveURI(archiveFile); FileObject resolvedFile = fsManager.resolveFile(absolutePath); if (fsManager.canCreateFileSystem(resolvedFile)) { fileSystem = fsManager.createFileSystem(resolvedFile); } else { fileSystem = resolvedFile;
public FileObject createVirtualFileSystem(final FileObject rootFile) throws FileSystemException { assert rootFile != null; return getManager().createVirtualFileSystem(rootFile); }
/** * Import a Tree * * @param file * @throws FileSystemException */ public void importTree(File file) throws FileSystemException { FileObject fileFo = getFileSystemManager().toFileObject(file); this.toRamFileObject(fileFo, fileFo); }
public FileObject createVirtualFileSystem(final String rootUri) throws FileSystemException { assert rootUri != null; FileObject file = getManager().resolveFile(rootUri); return getManager().createVirtualFileSystem(file); }
protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject to = VFS.getManager().resolveFile(url.toExternalForm()); File tmpFile = File.createTempFile("xxFilexx", ".json"); FileUtils.writeStringToFile(tmpFile, json); FileObject from = VFS.getManager().toFileObject(tmpFile); to.copyFrom(from, new AllFileSelector()); FileUtils.deleteQuietly(tmpFile); } else { FileUtils.writeStringToFile(FileUtils.toFile(url), json); } }
/** * Constructor * * @param rootFileUrl * The root directory of the repository. */ public LocalRepository(String rootFileUrl) { try { this.setFsManager(VFS.getManager()); this.root = this.fsManager.resolveFile(rootFileUrl); this.fsManager.createFileSystem(root); } catch (FileSystemException e) { e.printStackTrace(); } }
public FileObject createVirtualFileSystem(final FileObject rootFile) throws FileSystemException { assert rootFile != null; return getManager().createVirtualFileSystem(rootFile); }
public FileObject getCurrentDirectory(final Variables vars) throws FileSystemException { assert vars != null; FileObject cwd = null; Object var = vars.get(CWD); if (var instanceof String) { log.trace("Resolving CWD from string: {}", var); cwd = getManager().resolveFile((String)var); } else if (var instanceof FileObject) { cwd = (FileObject)var; } else if (var != null) { throw new RuntimeException("Invalid variable type for '" + CWD + "'; expected String or FileObject; found: " + var.getClass()); } if (cwd == null) { log.trace("CWD not set, resolving from user.dir"); // TODO: May need to ask the Application for this, as it might be different depending on the context (ie. remote user, etc) String userDir = "file://" + System.getProperty("user.dir"); cwd = getManager().resolveFile(userDir); } return cwd; }
public FileObject createVirtualFileSystem(final String rootUri) throws FileSystemException { assert rootUri != null; FileObject file = getManager().resolveFile(rootUri); return getManager().createVirtualFileSystem(file); }
public FileObject createVirtualFileSystem(final FileObject rootFile) throws FileSystemException { assert rootFile != null; return getManager().createVirtualFileSystem(rootFile); }
/** * Finds a file in this file system. */ public FileObject resolveFile(final String nameStr) throws FileSystemException { // Resolve the name, and create the file final FileName name = getFileSystemManager().resolveName(rootName, nameStr); return resolveFile(name); }
protected String readURL(URL url) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject from = VFS.getManager().resolveFile(url.toExternalForm()); return IOUtils.toString(from.getContent().getInputStream()); } else { return FileUtils.readFileToString(FileUtils.toFile(url)); } } }
public FsFileCollector( FileObject fsRoot ) throws FileSystemException { this.fsRoot = fsRoot; FileSystemManager fileSystemManager = fsRoot.getFileSystem().getFileSystemManager(); FileObject root = fileSystemManager.createVirtualFileSystem( fsRoot ); root.createFolder(); this.root = root; }