Search in sources :

Example 1 with GoogleDriveFileProvider

use of org.pentaho.googledrive.vfs.GoogleDriveFileProvider 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 GoogleDriveFileProvider

use of org.pentaho.googledrive.vfs.GoogleDriveFileProvider in project pentaho-kettle by pentaho.

the class GoogleDriveFileProviderTest method testFileProvider.

@Test
public void testFileProvider() throws Exception {
    GoogleDriveFileProvider fileProvider = new GoogleDriveFileProvider();
    assertTrue(fileProvider.SCHEME.equals(SCHEME));
    assertTrue(fileProvider.DISPLAY_NAME.equals(DISPLAY_NAME));
    FileName fileName = mock(FileName.class);
    FileSystemOptions options = new FileSystemOptions();
    assertNotNull(fileProvider.doCreateFileSystem(fileName, options));
}
Also used : FileName(org.apache.commons.vfs2.FileName) GoogleDriveFileProvider(org.pentaho.googledrive.vfs.GoogleDriveFileProvider) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions) Test(org.junit.Test)

Aggregations

GoogleDriveFileProvider (org.pentaho.googledrive.vfs.GoogleDriveFileProvider)2 File (java.io.File)1 FileName (org.apache.commons.vfs2.FileName)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 FileSystemManager (org.apache.commons.vfs2.FileSystemManager)1 FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)1 DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)1 Test (org.junit.Test)1 DefaultCapabilityManager (org.pentaho.capabilities.impl.DefaultCapabilityManager)1 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)1