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);
}
}
Aggregations