Search in sources :

Example 1 with IVersionCheckResultHandler

use of org.pentaho.versionchecker.IVersionCheckResultHandler 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 IVersionCheckResultHandler

use of org.pentaho.versionchecker.IVersionCheckResultHandler in project pentaho-platform by pentaho.

the class PentahoVersionCheckHelper method performUpdate.

public void performUpdate() {
    IVersionCheckResultHandler resultHandler = new IVersionCheckResultHandler() {

        public void processResults(String results) {
            // parse xml results vs spewing out xml?
            resultList.add(results);
        }
    };
    IVersionCheckErrorHandler errorHandler = new IVersionCheckErrorHandler() {

        public void handleException(Exception e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            resultList.add("<vercheck><error><![CDATA[" + e.getMessage() + "]]></error></vercheck>");
        }
    };
    // PentahoVersionCheckDataProvider dataProvider = new PentahoVersionCheckDataProvider();
    IVersionCheckDataProvider dataProvider = // $NON-NLS-1$
    PentahoSystem.get(IVersionCheckDataProvider.class, "IVersionCheckDataProvider", null);
    if (dataProvider == null) {
        dataProvider = new PentahoVersionCheckDataProvider();
    }
    if (versionRequestFlags != -1) {
        dataProvider.setVersionRequestFlags(versionRequestFlags);
    }
    VersionChecker vc = new VersionChecker();
    vc.setDataProvider(dataProvider);
    vc.addResultHandler(resultHandler);
    vc.addErrorHandler(errorHandler);
    vc.performCheck(ignoreExistingUpdates);
}
Also used : VersionChecker(org.pentaho.versionchecker.VersionChecker) IVersionCheckDataProvider(org.pentaho.versionchecker.IVersionCheckDataProvider) IVersionCheckResultHandler(org.pentaho.versionchecker.IVersionCheckResultHandler) IVersionCheckErrorHandler(org.pentaho.versionchecker.IVersionCheckErrorHandler)

Aggregations

IVersionCheckErrorHandler (org.pentaho.versionchecker.IVersionCheckErrorHandler)2 IVersionCheckResultHandler (org.pentaho.versionchecker.IVersionCheckResultHandler)2 VersionChecker (org.pentaho.versionchecker.VersionChecker)2 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)1 BasicVersionCheckerProvider (org.pentaho.versionchecker.BasicVersionCheckerProvider)1 IVersionCheckDataProvider (org.pentaho.versionchecker.IVersionCheckDataProvider)1