Search in sources :

Example 1 with DefaultCapabilityManager

use of org.pentaho.capabilities.impl.DefaultCapabilityManager 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)

Aggregations

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