SftpFileObjectWithWindowsSupport( AbstractFileName name, SftpFileSystemWindows fileSystem ) throws FileSystemException { super( name, fileSystem ); this.path = name.getPath(); }
protected void clearFileFromCache( FileName name ) { super.removeFileFromCache( name ); }
Putter( AtomicBoolean condition, DefaultFileSystemManager fsm ) { super( condition ); this.fsm = fsm; provider = mock( AbstractFileProvider.class ); doNothing().when( provider ).freeUnusedResources(); }
/** * {@link org.apache.commons.vfs2.provider.sftp.SftpFileSystem#getChannel() } * */ private void ensureSession() throws FileSystemException { if ( this.session == null || !this.session.isConnected() ) { this.doCloseCommunicationLink(); UserAuthenticationData authData = null; Session session; try { GenericFileName e = (GenericFileName) this.getRootName(); authData = UserAuthenticatorUtils.authenticate( this.getFileSystemOptions(), SftpFileProvider.AUTHENTICATOR_TYPES ); session = SftpClientFactory.createConnection( e.getHostName(), e.getPort(), UserAuthenticatorUtils.getData( authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar( e.getUserName() ) ), UserAuthenticatorUtils.getData( authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar( e.getPassword() ) ), this.getFileSystemOptions() ); } catch ( Exception var7 ) { throw new FileSystemException( "vfs.provider.sftp/connect.error", this.getRootName(), var7 ); } finally { UserAuthenticatorUtils.cleanup( authData ); } this.session = session; } }
private void updateLocation() { String pathText = wPath.getText(); String scheme = pathText.isEmpty() ? HDFS_SCHEME : UriParser.extractScheme( pathText ); if ( scheme != null ) { List<VFSScheme> availableVFSSchemes = getAvailableVFSSchemes(); for ( int i = 0; i < availableVFSSchemes.size(); i++ ) { VFSScheme s = availableVFSSchemes.get( i ); if ( scheme.equals( s.scheme ) ) { wLocation.select( i ); selectedVFSScheme = s; } } } }
FileNameParser sftpFilenameParser = SftpFileNameParser.getInstance(); URLFileName file = (URLFileName) sftpFilenameParser.parseUri( null, null, vfsUrl ); if ( !parameterContainsHost( fullParameterName ) || fullParameterName.endsWith( file.getHostName() ) ) { identities = new IdentityInfo[] { new IdentityInfo( new File( value ) ) }; } else { identities = temp; identities[identities.length - 1] = new IdentityInfo( new File( value ) );
private synchronized FileObject processFile( FileName name, boolean useCache ) throws FileSystemException { if ( !super.getRootName().getRootURI().equals( name.getRootURI() ) ) { throw new FileSystemException( "vfs.provider/mismatched-fs-for-name.error", new Object[] { name, super.getRootName(), name.getRootURI() } ); } else { FileObject file; if ( useCache ) { file = super.getFileFromCache( name ); } else { file = null; } if ( file == null ) { try { file = this.createFile( (AbstractFileName) name ); } catch ( Exception var5 ) { return null; } file = super.decorateFileObject( file ); if ( useCache ) { super.putFileToCache( file ); } } if ( super.getFileSystemManager().getCacheStrategy().equals( CacheStrategy.ON_RESOLVE ) ) { file.refresh(); } return file; } }
/** * Creates a temporary local copy of a file and its descendants. * * @param file the start of the tree. * @param selector selection what to do with childs. * @return replicated root file. * @throws Exception any Exception is wrapped as FileSystemException. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "input files are specified by admin, not unchecked user input") @Override public File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException { String baseName = srcFile.getName().getBaseName(); try { String safeBasename = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_'); File file = File.createTempFile("vfsr_", "_" + safeBasename, tempDir); file.deleteOnExit(); final FileObject destFile = context.toFileObject(file); destFile.copyFrom(srcFile, selector); return file; } catch (IOException e) { throw new FileSystemException(e); } }
/** * Create a FileContent implementation. * * @return The FileContent. * @throws FileSystemException if an error occurs. * @since 2.0 */ protected FileContent doCreateFileContent() throws FileSystemException { return new DefaultFileContent(this, getFileContentInfoFactory()); }
/** * Return the FileSystemManager used to instantiate this filesystem. * * @return the FileSystemManager. */ @Override public FileSystemManager getFileSystemManager() { return getContext().getFileSystemManager(); }
void streamOpened() { synchronized (this) { openStreams++; } ((AbstractFileSystem) fileObject.getFileSystem()).streamOpened(); }
@Override public URL getURL(final String basePath, final String file) throws MalformedURLException { if ((basePath != null && UriParser.extractScheme(basePath) == null) || (basePath == null && UriParser.extractScheme(file) == null)) { return super.getURL(basePath, file); } try { final FileSystemManager fsManager = VFS.getManager(); FileName path; if (basePath != null && UriParser.extractScheme(file) == null) { final FileName base = fsManager.resolveURI(basePath); path = fsManager.resolveName(base, file); } else { path = fsManager.resolveURI(file); } final URLStreamHandler handler = new VFSURLStreamHandler(path); return new URL(null, path.getURI(), handler); } catch (final FileSystemException fse) { throw new ConfigurationRuntimeException("Could not parse basePath: " + basePath + " and fileName: " + file, fse); } }
/** * Creates a temporary local copy of a file and its descendants. * * @param file the start of the tree. * @param selector selection what to do with childs. * @return replicated root file. * @throws Exception any Exception is wrapped as FileSystemException. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }
@Override public String getFileName(final String path) { if (UriParser.extractScheme(path) == null) { return super.getFileName(path); } try { final FileSystemManager fsManager = VFS.getManager(); final FileName name = fsManager.resolveURI(path); return name.getBaseName(); } catch (final FileSystemException fse) { fse.printStackTrace(); return null; } }
/** * Creates a temporary local copy of a file and its descendants. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }
@Override public String getBasePath(final String path) { if (UriParser.extractScheme(path) == null) { return super.getBasePath(path); } try { final FileSystemManager fsManager = VFS.getManager(); final FileName name = fsManager.resolveURI(path); return name.getParent().getURI(); } catch (final FileSystemException fse) { fse.printStackTrace(); return null; } }
/** * Creates a temporary local copy of a file and its descendants. * * @param file the start of the tree. * @param selector selection what to do with childs. * @return replicated root file. * @throws Exception any Exception is wrapped as FileSystemException. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }
@Override public URL locateFromURL(final String basePath, final String fileName) final String fileScheme = UriParser.extractScheme(fileName); if ((basePath == null || UriParser.extractScheme(basePath) == null) && fileScheme == null) final String scheme = UriParser.extractScheme(basePath); final FileSystemOptions opts = (scheme != null) ? getOptions(scheme) : null; FileObject base = (opts == null) ? fsManager.resolveFile(basePath)
if (UriParser.extractScheme(fileName) != null)