List of usage examples for org.apache.commons.vfs.impl StandardFileSystemManager StandardFileSystemManager
StandardFileSystemManager
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 ww w. ja va2 s . co 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:com.pongasoft.kiwidoc.builder.doclet.TestKiwidocBuilder.java
@Before public void setUp() throws IOException { _manager = new StandardFileSystemManager(); _manager.init(); }
From source file:net.sf.vfsjfilechooser.utils.VFSUtils.java
/** * Returns the global filesystem manager * @return the global filesystem manager */// w ww.ja v a2 s . co 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:com.adito.networkplaces.NetworkPlacePlugin.java
void initFileSystems() throws FileSystemException { VFSProviderManager mgr = VFSProviderManager.getInstance(); // Intialise the additional commons vfs providers /*/*from w w w. ja v a 2 s.c o m*/ ((StandardFileSystemManager)VFS.getManager()).addProvider("webdav", new WebdavFileProvider()); */ // //NOTE: This Code for Old Apache Commons VFS /* ((StandardFileSystemManager)VFS.getManager()).addProvider("jar", new JarFileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider("zip", new ZipFileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider("tar", new TarFileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider("tgz", new TgzFileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider("tbz2", new Tbz2FileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider("gz", new GzipFileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider("tmp", new TemporaryFileProvider()); ((StandardFileSystemManager)VFS.getManager()).addProvider(new String[] { "bzip2", "bz2" }, new Bzip2FileProvider()); */ //NOTE: This Code for Apache Commons VFS StandardFileSystemManager sfsm = new StandardFileSystemManager(); sfsm.addProvider("jar", new JarFileProvider()); sfsm.addProvider("zip", new ZipFileProvider()); sfsm.addProvider("tar", new TarFileProvider()); sfsm.addProvider("tgz", new TgzFileProvider()); sfsm.addProvider("tbz2", new Tbz2FileProvider()); sfsm.addProvider("gz", new GzipFileProvider()); sfsm.addProvider("tmp", new TemporaryFileProvider()); sfsm.addProvider(new String[] { "bzip2", "bz2" }, new Bzip2FileProvider()); sfsm.addProvider("sftp", new SftpFileProvider()); sfsm.addProvider("cifs", new SmbFileProvider()); sfsm.addProvider("webdav", new WebdavFileProvider()); mgr.registerProvider(new FileProvider()); mgr.registerProvider(new FTPProvider()); mgr.registerProvider(new SFTPProvider()); mgr.registerProvider(new CIFSProvider()); mgr.registerProvider(new JarProvider()); mgr.registerProvider(new ZipProvider()); mgr.registerProvider(new WebDAVProvider()); /* Don't seem to work as expected. mgr.registerProvider(new TarProvider()); mgr.registerProvider(new WebDAVProvider()); mgr.registerProvider(new TgzProvider()); mgr.registerProvider(new Tbz2Provider()); */ }
From source file:org.apache.ivy.plugins.repository.vfs.VfsRepository.java
private StandardFileSystemManager createVFSManager() throws IOException { StandardFileSystemManager result = null; try {//from w ww. j a v a 2 s . c om /* * 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.apache.ivy.plugins.repository.vfs.VfsTestHelper.java
public VfsTestHelper() throws Exception { // setup and initialize VFS fsManager = new StandardFileSystemManager() { protected void configurePlugins() throws FileSystemException { // disable automatic loading potential unsupported extensions }/* w ww.ja v a 2 s . c o m*/ }; fsManager.setConfiguration(getClass().getResource(VFS_CONF).toString()); fsManager.init(); // setup and initialize ivy ivy = new Ivy(); ivy.configure(new File(IVY_CONFIG_FILE)); }
From source file:org.codehaus.cargo.container.installer.ZipURLInstallerTest.java
/** * Creates the test ZIP URL installer and its fils system manager. {@inheritDoc} * @throws Exception If anything goes wrong. *//* w ww. j av a2 s .c o m*/ @Override protected void setUp() throws Exception { super.setUp(); this.fsManager = new StandardFileSystemManager(); this.fsManager.init(); this.fileHandler = new VFSFileHandler(this.fsManager); this.installer = new ZipURLInstaller(new URL("http://some/url/resin-3.0.18.zip")); this.installer.setFileHandler(this.fileHandler); }
From source file:org.codehaus.cargo.container.jboss.internal.JBossInstalledLocalContainerTest.java
/** * Creates the test file system manager and the container. {@inheritDoc} * @throws Exception If anything goes wrong. *//*from www. j a va2 s . co m*/ @Override protected void setUp() throws Exception { super.setUp(); this.fsManager = new StandardFileSystemManager(); this.fsManager.init(); this.fileHandler = new VFSFileHandler(this.fsManager); this.fileHandler.createDirectory(CONTAINER_HOME + "/server", SERVER_CONFIG); LocalConfiguration configuration = new JBossStandaloneLocalConfiguration(CONFIGURATION_HOME); configuration.setProperty(JBossPropertySet.CONFIGURATION, SERVER_CONFIG); this.container = new JBoss4xInstalledLocalContainer(configuration); this.container.setHome(CONTAINER_HOME); this.container.setFileHandler(this.fileHandler); }
From source file:org.codehaus.cargo.container.jonas.Jonas4xExistingLocalConfigurationTest.java
/** * Creates the test file system manager and the container. {@inheritDoc} * @throws Exception If anything goes wrong. *//*from ww w . j av a 2 s.c o m*/ @Override protected void setUp() throws Exception { super.setUp(); this.fsManager = new StandardFileSystemManager(); this.fsManager.init(); this.fileHandler = new VFSFileHandler(this.fsManager); this.fileHandler.createDirectory(null, JONAS_ROOT); this.configuration = new Jonas4xExistingLocalConfiguration(JONAS_ROOT); this.configuration.setFileHandler(fileHandler); this.container = new Jonas4xInstalledLocalContainer(configuration); this.container.setFileHandler(this.fileHandler); this.container.setHome(JONAS_ROOT); }
From source file:org.codehaus.cargo.container.jonas.Jonas4xInstalledLocalContainerTest.java
/** * Creates the test file system manager and the container. {@inheritDoc} * @throws Exception If anything goes wrong. *///from w ww . j av a 2 s. c o m @Override protected void setUp() throws Exception { super.setUp(); this.fsManager = new StandardFileSystemManager(); this.fsManager.init(); this.fileHandler = new VFSFileHandler(this.fsManager); this.fileHandler.createDirectory(null, JONAS_ROOT); this.fileHandler.createDirectory(null, JONAS_BASE); LocalConfiguration configuration = new Jonas4xStandaloneLocalConfiguration(JONAS_BASE); this.container = new Jonas4xInstalledLocalContainer(configuration); this.container.setFileHandler(this.fileHandler); this.container.setHome(JONAS_ROOT); }