List of usage examples for org.apache.commons.vfs2.impl DefaultFileSystemManager addProvider
public void addProvider(final String[] urlSchemes, final FileProvider provider) throws FileSystemException
From source file:com.sludev.commons.vfs2.provider.azure.AzTestUtils.java
public static void deleteFile(String accntName, String accntHost, String accntKey, String containerName, Path remotePath) throws FileSystemException { DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.init();/*from w ww . ja v a2 s .co m*/ StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, accntHost, containerName, remotePath); FileObject currFile = currMan.resolveFile(currUriStr, opts); Boolean delRes = currFile.delete(); Assert.assertTrue(delRes); }
From source file:com.sludev.commons.vfs2.provider.s3.SS3TestUtils.java
public static void deleteFile(String accntName, String accntHost, String accntKey, String containerName, Path remotePath) throws FileSystemException { DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(SS3Constants.S3SCHEME, new SS3FileProvider()); currMan.init();// w w w .j ava2s . c o m StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); String currUriStr = String.format("%s://%s/%s/%s", SS3Constants.S3SCHEME, accntHost, containerName, remotePath); FileObject currFile = currMan.resolveFile(currUriStr, opts); Boolean delRes = currFile.delete(); Assert.assertTrue(delRes); }
From source file:com.sludev.commons.vfs2.provider.azure.AzTestUtils.java
public static void uploadFile(String accntName, String accntHost, String accntKey, String containerName, Path localFile, Path remotePath) throws FileSystemException { DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.addProvider("file", new DefaultLocalFileProvider()); currMan.init();// w w w.j a va2 s .c om StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, accntHost, containerName, remotePath); FileObject currFile = currMan.resolveFile(currUriStr, opts); FileObject currFile2 = currMan.resolveFile(String.format("file://%s", localFile)); currFile.copyFrom(currFile2, Selectors.SELECT_SELF); currFile.close(); currMan.close(); }
From source file:com.sludev.commons.vfs2.provider.s3.SS3TestUtils.java
public static void uploadFile(String accntName, String acctHost, String accntKey, String containerName, Path localFile, Path remotePath) throws FileSystemException { DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(SS3Constants.S3SCHEME, new SS3FileProvider()); currMan.addProvider("file", new DefaultLocalFileProvider()); currMan.init();/* w w w . j a v a 2s . com*/ StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); String currUriStr = String.format("%s://%s/%s/%s", SS3Constants.S3SCHEME, acctHost, containerName, remotePath); FileObject currFile = currMan.resolveFile(currUriStr, opts); FileObject currFile2 = currMan.resolveFile(String.format("file://%s", localFile)); currFile.copyFrom(currFile2, Selectors.SELECT_SELF); currFile.close(); currMan.close(); }
From source file:de.unioninvestment.portal.explorer.view.vfs.VFSMainView.java
public static DefaultFileSystemManager getManager() throws FileSystemException { DefaultFileSystemManager mngr = new DefaultFileSystemManager(); mngr.addProvider("sftp", new SftpFileProvider()); mngr.addProvider("ftp", new FtpFileProvider()); mngr.addProvider("file", new DefaultLocalFileProvider()); mngr.init();/* w w w . ja v a2 s. com*/ return mngr; }
From source file:com.sludev.commons.vfs2.provider.azure.AzFileProviderTest.java
@Test public void A007_deleteFile() throws Exception { String currAccountStr = testProperties.getProperty("azure.account.name"); String currKey = testProperties.getProperty("azure.account.key"); String currContainerStr = testProperties.getProperty("azure.test0001.container.name"); String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net String currFileNameStr;// w w w .j a v a 2s . c om DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.init(); StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); currFileNameStr = "test01.tmp"; String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr); FileObject currFile = currMan.resolveFile(currUriStr, opts); log.info(String.format("deleting '%s'", currUriStr)); Boolean delRes = currFile.delete(); Assert.assertTrue(delRes); }
From source file:com.sludev.commons.vfs2.provider.azure.AzFileProviderTest.java
@Test public void A006_testContent() throws Exception { String currAccountStr = testProperties.getProperty("azure.account.name"); String currKey = testProperties.getProperty("azure.account.key"); String currContainerStr = testProperties.getProperty("azure.test0001.container.name"); String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net String currFileNameStr;//from ww w . ja v a2 s.c om DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.init(); StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); currFileNameStr = "file05"; String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr); FileObject currFile = currMan.resolveFile(currUriStr, opts); FileContent content = currFile.getContent(); long size = content.getSize(); Assert.assertTrue(size >= 0); long modTime = content.getLastModifiedTime(); Assert.assertTrue(modTime > 0); }
From source file:com.sludev.commons.vfs2.provider.azure.AzFileProviderTest.java
@Test public void A004_getContentSize() throws Exception { String currAccountStr = testProperties.getProperty("azure.account.name"); String currKey = testProperties.getProperty("azure.account.key"); String currContainerStr = testProperties.getProperty("azure.test0001.container.name"); String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net String currFileNameStr;/*from w ww. ja va 2 s .c o m*/ DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.init(); StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); currFileNameStr = "test01.tmp"; String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr); FileObject currFile = currMan.resolveFile(currUriStr, opts); log.info(String.format("exist() file '%s'", currUriStr)); FileContent cont = currFile.getContent(); long contSize = cont.getSize(); Assert.assertTrue(contSize > 0); }
From source file:com.sludev.commons.vfs2.provider.azure.AzFileProviderTest.java
/** * By default FileObject.getChildren() will use doListChildrenResolved() if available * /* ww w . ja v a 2 s . com*/ * @throws Exception */ @Test public void A005_listChildren() throws Exception { String currAccountStr = testProperties.getProperty("azure.account.name"); String currKey = testProperties.getProperty("azure.account.key"); String currContainerStr = testProperties.getProperty("azure.test0001.container.name"); String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.init(); StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); String currFileNameStr = "uploadFile02"; String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr); FileObject currFile = currMan.resolveFile(currUriStr, opts); FileObject[] currObjs = currFile.getChildren(); for (FileObject obj : currObjs) { FileName currName = obj.getName(); Boolean res = obj.exists(); FileType ft = obj.getType(); log.info(String.format("\nNAME.PATH : '%s'\nEXISTS : %b\nTYPE : %s\n\n", currName.getPath(), res, ft)); } }
From source file:com.sludev.commons.vfs2.provider.azure.AzFileProviderTest.java
@Test public void A002_downloadFile() throws Exception { String currAccountStr = testProperties.getProperty("azure.account.name"); String currKey = testProperties.getProperty("azure.account.key"); String currContainerStr = testProperties.getProperty("azure.test0001.container.name"); String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net String currFileNameStr;/*from ww w. j a v a 2 s.c o m*/ File temp = File.createTempFile("downloadFile01", ".tmp"); DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.addProvider("file", new DefaultLocalFileProvider()); currMan.init(); StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); currFileNameStr = "test01.tmp"; String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr); FileObject currFile = currMan.resolveFile(currUriStr, opts); String destStr = String.format("file://%s", temp.getAbsolutePath()); FileObject currFile2 = currMan.resolveFile(destStr); log.info(String.format("copying '%s' to '%s'", currUriStr, destStr)); currFile2.copyFrom(currFile, Selectors.SELECT_SELF); }