Search in sources :

Example 1 with LifecycleException

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();
}
Also used : VersionChecker(org.pentaho.versionchecker.VersionChecker) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) IVersionCheckResultHandler(org.pentaho.versionchecker.IVersionCheckResultHandler) BasicVersionCheckerProvider(org.pentaho.versionchecker.BasicVersionCheckerProvider) IVersionCheckErrorHandler(org.pentaho.versionchecker.IVersionCheckErrorHandler) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException)

Example 2 with LifecycleException

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);
    }
}
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 3 with LifecycleException

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;
}
Also used : LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) TransMeta(org.pentaho.di.trans.TransMeta) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 4 with LifecycleException

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)4 MessageBox (org.eclipse.swt.widgets.MessageBox)2 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 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 DefaultCapabilityManager (org.pentaho.capabilities.impl.DefaultCapabilityManager)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1 Point (org.pentaho.di.core.gui.Point)1 TransMeta (org.pentaho.di.trans.TransMeta)1 TransGraph (org.pentaho.di.ui.spoon.trans.TransGraph)1 GoogleDriveFileProvider (org.pentaho.googledrive.vfs.GoogleDriveFileProvider)1 BasicVersionCheckerProvider (org.pentaho.versionchecker.BasicVersionCheckerProvider)1 IVersionCheckErrorHandler (org.pentaho.versionchecker.IVersionCheckErrorHandler)1 IVersionCheckResultHandler (org.pentaho.versionchecker.IVersionCheckResultHandler)1 VersionChecker (org.pentaho.versionchecker.VersionChecker)1