List of usage examples for org.apache.commons.vfs.impl StandardFileSystemManager init
public void init() throws FileSystemException
From source file:net.sf.vfsjfilechooser.utils.VFSUtils.java
/** * Returns the global filesystem manager * @return the global filesystem manager *///from ww w .j av a2 s .c o m public static FileSystemManager getFileSystemManager() { aLock.readLock().lock(); try { if (fileSystemManager == null) { try { StandardFileSystemManager fm = new StandardFileSystemManager(); fm.setCacheStrategy(CacheStrategy.MANUAL); fm.init(); fileSystemManager = fm; } catch (Exception exc) { throw new RuntimeException(exc); } } return fileSystemManager; } finally { aLock.readLock().unlock(); } }
From source file:gov.nih.nci.cacis.ip.mirthconnect.ftp.SFTPSender.java
public void sendDocument(InputStream file, String ftpAddress, String extension) { StandardFileSystemManager standardFileSystemManager = new StandardFileSystemManager(); try {/*from w w w . j a va 2s .c o m*/ final FTPInfo ftpInfo = ftpMapping.getFTPInfo(ftpAddress); if (ftpInfo == null) { throw new ApplicationRuntimeException("No server config exists for address[ " + ftpAddress + " ]"); } String sftpURI = "sftp://" + ftpInfo.getUserName() + ":" + ftpInfo.getPassword() + "@" + ftpInfo.getSite() + "/" + ftpInfo.getRootDirectory(); String fileName = "IHEXIPFTP-" + UUID.randomUUID() + extension; FileSystemOptions fileSystemOptions = new FileSystemOptions(); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fileSystemOptions, "no"); SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(fileSystemOptions, true); standardFileSystemManager.init(); FileObject fileObject = standardFileSystemManager.resolveFile(sftpURI + "/" + fileName, fileSystemOptions); long timestamp = new Date().getTime(); String tempSftpFile = sftpFileDirectory + "/" + timestamp + ".xml"; OutputStream out = new FileOutputStream(new File(tempSftpFile)); int read = 0; byte[] bytes = new byte[1024]; while ((read = file.read(bytes)) != -1) { out.write(bytes, 0, read); } file.close(); out.flush(); out.close(); FileObject localFileObject = standardFileSystemManager.resolveFile(tempSftpFile); fileObject.copyFrom(localFileObject, Selectors.SELECT_SELF); FileUtils.forceDelete(new File(tempSftpFile)); } catch (Exception e) { throw new ApplicationRuntimeException("Error sending SFTP. " + e.getMessage()); } finally { standardFileSystemManager.close(); } }
From source file:org.apache.ivy.plugins.repository.vfs.VfsRepository.java
private StandardFileSystemManager createVFSManager() throws IOException { StandardFileSystemManager result = null; try {/*from w w w.j a va 2 s .com*/ /* * The DefaultFileSystemManager gets its configuration from the jakarta-vfs-common * implementation which includes the res and tmp schemes which are of no use to use * here. Using StandardFileSystemManager lets us specify which schemes to support as * well as providing a mechanism to change this support without recompilation. */ result = new StandardFileSystemManager() { protected void configurePlugins() throws FileSystemException { // disable automatic loading potential unsupported extensions } }; result.setConfiguration(getClass().getResource(IVY_VFS_CONFIG)); result.init(); // Generate and print a list of available schemes Message.verbose("Available VFS schemes..."); String[] schemes = result.getSchemes(); Arrays.sort(schemes); for (int i = 0; i < schemes.length; i++) { Message.verbose("VFS Supported Scheme: " + schemes[i]); } } catch (FileSystemException e) { /* * If our attempt to initialize a VFS Repository fails we log the failure but continue * on. Given that an Ivy instance may involve numerous different repository types, it * seems overly cautious to throw a runtime exception on the initialization failure of * just one repository type. */ Message.error("Unable to initialize VFS repository manager!"); Message.error(e.getLocalizedMessage()); IOException error = new IOException(e.getLocalizedMessage()); error.initCause(e); throw error; } return result; }
From source file:org.docx4j.extras.vfs.VFSUtils.java
public static FileSystemManager getFileSystemManager() { aLock.readLock().lock();//from w w w . j av a 2 s . c o m try { if (fileSystemManager == null) { try { StandardFileSystemManager fm = new StandardFileSystemManager(); fm.setCacheStrategy(CacheStrategy.MANUAL); fm.init(); fileSystemManager = fm; } catch (Exception exc) { throw new RuntimeException(exc); } } return fileSystemManager; } finally { aLock.readLock().unlock(); } }
From source file:org.mule.transports.vfs.VFSConnector.java
private FileSystemManager createFileSystemManager() throws FileSystemException { StandardFileSystemManager fsm = new StandardFileSystemManager(); fsm.init(); return fsm;/* w w w .j a v a 2 s .co m*/ }