Search in sources :

Example 1 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project pentaho-kettle by pentaho.

the class GoogleDrivePluginLifecycleListener method onEnvironmentInit.

public void onEnvironmentInit() throws LifecycleException {
    try {
        boolean proceed = true;
        if (!new File(GoogleDriveFileObject.resolveCredentialsPath() + "/" + resourceBundle.getString("client.secrets")).exists()) {
            proceed = false;
            log.warn("The Google Authorization secrets security token file (" + resourceBundle.getString("client.secrets") + ") is not present in the credentials folder. This file is necessary to activate the Google Drive VFS plugin.");
        }
        if (!new File(GoogleDriveFileObject.resolveCredentialsPath() + "/" + resourceBundle.getString("stored.credential")).exists()) {
            DefaultCapabilityManager capabilityManager = DefaultCapabilityManager.getInstance();
            if (capabilityManager.capabilityExist("pentaho-server")) {
                proceed = false;
                log.warn("The Google Authorization Code Flow security token file (" + resourceBundle.getString("stored.credential") + ") is not present in the credentials folder.  This file is necessary to activate the Google Drive VFS plugin.");
            }
        }
        /**
         * Registers the GoogleDrive VFS File Provider dynamically since it is bundled with our plugin and will not automatically
         * be registered through the normal class path search the default FileSystemManager performs.
         */
        if (proceed) {
            FileSystemManager fsm = KettleVFS.getInstance().getFileSystemManager();
            if (fsm instanceof DefaultFileSystemManager) {
                if (!Arrays.asList(fsm.getSchemes()).contains(GoogleDriveFileProvider.SCHEME)) {
                    ((DefaultFileSystemManager) fsm).addProvider(GoogleDriveFileProvider.SCHEME, new GoogleDriveFileProvider());
                }
            }
        }
    } catch (FileSystemException e) {
        throw new LifecycleException(e.getMessage(), false);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) DefaultCapabilityManager(org.pentaho.capabilities.impl.DefaultCapabilityManager) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) GoogleDriveFileProvider(org.pentaho.googledrive.vfs.GoogleDriveFileProvider) File(java.io.File) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) FileSystemManager(org.apache.commons.vfs2.FileSystemManager)

Example 2 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project accumulo by apache.

the class AccumuloVFSClassLoader method generateVfs.

public static FileSystemManager generateVfs() throws FileSystemException {
    DefaultFileSystemManager vfs = new DefaultFileSystemManager();
    vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
    vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
    vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
    vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider());
    vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider());
    vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider());
    vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider());
    vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider());
    vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider());
    vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
    vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider());
    vfs.addProvider("hdfs", new HdfsFileProvider());
    vfs.addExtensionMap("jar", "jar");
    vfs.addExtensionMap("zip", "zip");
    vfs.addExtensionMap("gz", "gz");
    vfs.addExtensionMap("tar", "tar");
    vfs.addExtensionMap("tbz2", "tar");
    vfs.addExtensionMap("tgz", "tar");
    vfs.addExtensionMap("bz2", "bz2");
    vfs.addMimeTypeMap("application/x-tar", "tar");
    vfs.addMimeTypeMap("application/x-gzip", "gz");
    vfs.addMimeTypeMap("application/zip", "zip");
    vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
    vfs.setFilesCache(new SoftRefFilesCache());
    File cacheDir = computeTopCacheDir();
    vfs.setReplicator(new UniqueFileReplicator(cacheDir));
    vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
    vfs.init();
    vfsInstances.add(new WeakReference<>(vfs));
    return vfs;
}
Also used : HdfsFileProvider(org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider) FileContentInfoFilenameFactory(org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory) SoftRefFilesCache(org.apache.commons.vfs2.cache.SoftRefFilesCache) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) File(java.io.File)

Example 3 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project spoofax by metaborg.

the class DefaultFileSystemManagerProvider method addDefaultProvider.

protected void addDefaultProvider(DefaultFileSystemManager manager) throws FileSystemException {
    final DefaultLocalFileProvider provider = new DefaultLocalFileProvider();
    manager.addProvider("file", provider);
    manager.setDefaultProvider(provider);
}
Also used : DefaultLocalFileProvider(org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider)

Example 4 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project spoofax by metaborg.

the class DefaultFileSystemManagerProvider method get.

@Override
public FileSystemManager get() {
    try {
        final DefaultFileSystemManager manager = new DefaultFileSystemManager();
        manager.setFilesCache(new DefaultFilesCache());
        manager.setCacheStrategy(CacheStrategy.ON_RESOLVE);
        final String baseTmpDir = System.getProperty("java.io.tmpdir");
        final File tempDir = new File(baseTmpDir, "vfs_cache" + new Random().nextLong()).getAbsoluteFile();
        final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);
        manager.setTemporaryFileStore(replicator);
        manager.setReplicator(replicator);
        addDefaultProvider(manager);
        addProviders(manager);
        setBaseFile(manager);
        manager.init();
        return manager;
    } catch (FileSystemException e) {
        throw new RuntimeException("Cannot initialize resource service: " + e.getMessage(), e);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) Random(java.util.Random) DefaultFilesCache(org.apache.commons.vfs2.cache.DefaultFilesCache) DefaultFileReplicator(org.apache.commons.vfs2.impl.DefaultFileReplicator) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) File(java.io.File)

Example 5 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project spoofax by metaborg.

the class DefaultFileSystemManagerProvider method addProviders.

protected void addProviders(DefaultFileSystemManager manager) throws FileSystemException {
    manager.addProvider("tmp", new TemporaryFileProvider());
    manager.addProvider("res", new ResourceFileProvider());
    manager.addProvider("ram", new RamFileProvider());
    manager.addProvider("zip", new ZipFileProvider());
    manager.addProvider("jar", new JarFileProvider());
    manager.addProvider("tar", new TarFileProvider());
    manager.addProvider("tgz", new TgzFileProvider());
    manager.addProvider("tbz2", new Tbz2FileProvider());
    manager.addProvider("gz", new GzipFileProvider());
    manager.addProvider("bz2", new Bzip2FileProvider());
    manager.addProvider("http", new HttpFileProvider());
    manager.addProvider("https", new HttpsFileProvider());
    manager.addProvider("webdav", new WebdavFileProvider());
    manager.addProvider("ftp", new FtpFileProvider());
    manager.addProvider("ftps", new FtpsFileProvider());
}
Also used : JarFileProvider(org.apache.commons.vfs2.provider.jar.JarFileProvider) FtpFileProvider(org.apache.commons.vfs2.provider.ftp.FtpFileProvider) ZipFileProvider(org.apache.commons.vfs2.provider.zip.ZipFileProvider) Bzip2FileProvider(org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider) TarFileProvider(org.apache.commons.vfs2.provider.tar.TarFileProvider) TemporaryFileProvider(org.apache.commons.vfs2.provider.temp.TemporaryFileProvider) HttpFileProvider(org.apache.commons.vfs2.provider.http.HttpFileProvider) Tbz2FileProvider(org.apache.commons.vfs2.provider.tar.Tbz2FileProvider) GzipFileProvider(org.apache.commons.vfs2.provider.gzip.GzipFileProvider) HttpsFileProvider(org.apache.commons.vfs2.provider.https.HttpsFileProvider) TgzFileProvider(org.apache.commons.vfs2.provider.tar.TgzFileProvider) FtpsFileProvider(org.apache.commons.vfs2.provider.ftps.FtpsFileProvider) ResourceFileProvider(org.apache.commons.vfs2.provider.res.ResourceFileProvider) RamFileProvider(org.apache.commons.vfs2.provider.ram.RamFileProvider) WebdavFileProvider(org.apache.commons.vfs2.provider.webdav.WebdavFileProvider)

Aggregations

DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)10 FileSystemException (org.apache.commons.vfs2.FileSystemException)7 File (java.io.File)5 IOException (java.io.IOException)5 FileSystemManager (org.apache.commons.vfs2.FileSystemManager)4 SoftRefFilesCache (org.apache.commons.vfs2.cache.SoftRefFilesCache)3 DefaultFileReplicator (org.apache.commons.vfs2.impl.DefaultFileReplicator)3 FileContentInfoFilenameFactory (org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory)3 StandardFileSystemManager (org.apache.commons.vfs2.impl.StandardFileSystemManager)3 HdfsFileProvider (org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider)3 RepositoryException (javax.jcr.RepositoryException)2 DefaultFilesCache (org.apache.commons.vfs2.cache.DefaultFilesCache)2 FileReplicator (org.apache.commons.vfs2.provider.FileReplicator)2 Random (java.util.Random)1 UniqueFileReplicator (org.apache.accumulo.start.classloader.vfs.UniqueFileReplicator)1 NotImplementedException (org.apache.commons.lang.NotImplementedException)1 Bzip2FileProvider (org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider)1 FtpFileProvider (org.apache.commons.vfs2.provider.ftp.FtpFileProvider)1 FtpsFileProvider (org.apache.commons.vfs2.provider.ftps.FtpsFileProvider)1 GzipFileProvider (org.apache.commons.vfs2.provider.gzip.GzipFileProvider)1