use of org.pentaho.di.core.lifecycle.LifecycleException in project pentaho-kettle by pentaho.
the class VersionCheckerListener method onStart.
/**
* Interface method: checks the version
*/
public void onStart(final LifeEventHandler handler) throws LifecycleException {
// Should we run this listener?
String prop = Props.getInstance().getProperty(PDI_CHECK_VERSION_FLAG);
if (prop != null && !Boolean.parseBoolean(prop)) {
log.logBasic("Skipping version check.", new Object[] {});
return;
}
try {
// check to see if pentaho version checker is in the classpath
//
Class.forName("org.pentaho.versionchecker.BasicVersionCheckerProvider");
} catch (ClassNotFoundException e) {
return;
}
Runnable r = new Runnable() {
public void run() {
final BasicVersionCheckerProvider dataProvider = new BasicVersionCheckerProvider(Spoon.class);
VersionChecker vc = new VersionChecker();
vc.setDataProvider(dataProvider);
vc.addResultHandler(new IVersionCheckResultHandler() {
public void processResults(String result) {
}
});
vc.addErrorHandler(new IVersionCheckErrorHandler() {
public void handleException(Exception e) {
root = new LifecycleException(e, false);
}
});
vc.performCheck(false);
if (root != null)
return;
}
};
new Thread(r).start();
}
use of org.pentaho.di.core.lifecycle.LifecycleException 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);
}
}
use of org.pentaho.di.core.lifecycle.LifecycleException in project pentaho-kettle by pentaho.
the class Spoon method quitFile.
public boolean quitFile(boolean canCancel) throws KettleException {
if (log.isDetailed()) {
// "Quit application."
log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.QuitApplication"));
}
boolean exit = true;
saveSettings();
if (props.showExitWarning() && canCancel) {
// Display message: are you sure you want to exit?
//
MessageDialogWithToggle md = new MessageDialogWithToggle(shell, // "Warning!"
BaseMessages.getString(PKG, "System.Warning"), null, BaseMessages.getString(PKG, "Spoon.Message.Warning.PromptExit"), MessageDialog.WARNING, new String[] { // "Yes",
BaseMessages.getString(PKG, "Spoon.Message.Warning.Yes"), // "No"
BaseMessages.getString(PKG, "Spoon.Message.Warning.No") }, 1, // "Please, don't show this warning anymore."
BaseMessages.getString(PKG, "Spoon.Message.Warning.NotShowWarning"), !props.showExitWarning());
MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
int idx = md.open();
props.setExitWarningShown(!md.getToggleState());
props.saveProps();
if ((idx & 0xFF) == 1) {
// No selected: don't exit!
return false;
}
}
// Check all tabs to see if we can close them...
//
List<TabMapEntry> list = delegates.tabs.getTabs();
for (TabMapEntry mapEntry : list) {
TabItemInterface itemInterface = mapEntry.getObject();
if (!itemInterface.canBeClosed()) {
// Show the tab
tabfolder.setSelected(mapEntry.getTabItem());
// Unsaved work that needs to changes to be applied?
//
int reply = itemInterface.showChangedWarning();
if (reply == SWT.YES) {
// If there is a fatal error, give the user opportunity to rename file w/out overwriting existing file
if (hasFatalError) {
saveFileAs(itemInterface.getMeta());
} else {
exit = itemInterface.applyChanges();
}
} else {
if (reply == SWT.CANCEL) {
return false;
} else {
// SWT.NO
exit = true;
}
}
}
}
if (exit || !canCancel) {
// all the tabs, stop the running transformations
for (TabMapEntry mapEntry : list) {
if (!mapEntry.getObject().canBeClosed()) {
//
if (mapEntry.getObject() instanceof TransGraph) {
TransMeta transMeta = (TransMeta) mapEntry.getObject().getManagedObject();
if (transMeta.hasChanged()) {
delegates.tabs.removeTab(mapEntry);
}
}
//
if (mapEntry.getObject() instanceof TransGraph) {
TransGraph transGraph = (TransGraph) mapEntry.getObject();
if (transGraph.isRunning()) {
transGraph.stop();
delegates.tabs.removeTab(mapEntry);
}
}
}
}
}
try {
lifecycleSupport.onExit(this);
} catch (LifecycleException e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
box.setMessage(e.getMessage());
box.open();
}
if (exit) {
// so we first move the focus to somewhere else
if (this.designTreeToolbar != null && !this.designTreeToolbar.isDisposed()) {
this.designTreeToolbar.forceFocus();
}
close();
}
return exit;
}
use of org.pentaho.di.core.lifecycle.LifecycleException in project pentaho-kettle by pentaho.
the class Spoon method createContents.
@Override
protected Control createContents(Composite parent) {
shell = getShell();
init(null);
openSpoon();
//
try {
lifecycleSupport.onStart(this);
} catch (LifecycleException e) {
// if severe, we have to quit
MessageBox box = new MessageBox(shell, (e.isSevere() ? SWT.ICON_ERROR : SWT.ICON_WARNING) | SWT.OK);
box.setMessage(e.getMessage());
box.open();
}
try {
start(commandLineOptions);
} catch (KettleException e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
box.setMessage(e.getMessage());
box.open();
}
getMenuBarManager().updateAll(true);
return parent;
}
Aggregations