Search in sources :

Example 26 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class AuthenticationPersistenceManager method getAuthenticationManager.

public static AuthenticationManager getAuthenticationManager() {
    AuthenticationManager manager = new AuthenticationManager();
    manager.registerAuthenticationProvider(new NoAuthenticationAuthenticationProvider());
    for (PluginInterface plugin : PluginRegistry.getInstance().getPlugins(AuthenticationConsumerPluginType.class)) {
        try {
            Object pluginMain = PluginRegistry.getInstance().loadClass(plugin);
            if (pluginMain instanceof AuthenticationConsumerType) {
                Class<? extends AuthenticationConsumer<?, ?>> consumerClass = ((AuthenticationConsumerType) pluginMain).getConsumerClass();
                manager.registerConsumerClass(consumerClass);
            } else {
                throw new KettlePluginException(BaseMessages.getString(PKG, "AuthenticationPersistenceManager.NotConsumerType", pluginMain, AuthenticationConsumerType.class));
            }
        } catch (KettlePluginException e) {
            log.logError(e.getMessage(), e);
        } catch (AuthenticationFactoryException e) {
            log.logError(e.getMessage(), e);
        }
    }
    return manager;
}
Also used : AuthenticationManager(org.pentaho.di.core.auth.core.AuthenticationManager) AuthenticationFactoryException(org.pentaho.di.core.auth.core.AuthenticationFactoryException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 27 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class CompressionProviderFactory method getCompressionProviderByName.

@Override
public CompressionProvider getCompressionProviderByName(String name) {
    if (name == null) {
        return null;
    }
    CompressionProvider foundProvider = null;
    List<PluginInterface> providers = getPlugins();
    if (providers != null) {
        for (PluginInterface plugin : providers) {
            try {
                CompressionProvider provider = PluginRegistry.getInstance().loadClass(plugin, CompressionProvider.class);
                if (provider != null && name.equals(provider.getName())) {
                    foundProvider = provider;
                }
            } catch (Exception e) {
            // Do nothing here, if we can't load the provider, don't add it to the list
            }
        }
    }
    return foundProvider;
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 28 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class RepositoryConnectController method getPlugins.

@SuppressWarnings("unchecked")
public String getPlugins() {
    List<PluginInterface> plugins = pluginRegistry.getPlugins(RepositoryPluginType.class);
    JSONArray list = new JSONArray();
    for (PluginInterface pluginInterface : plugins) {
        if (!pluginInterface.getIds()[0].equals("PentahoEnterpriseRepository")) {
            JSONObject repoJSON = new JSONObject();
            repoJSON.put("id", pluginInterface.getIds()[0]);
            repoJSON.put("name", pluginInterface.getName());
            repoJSON.put("description", pluginInterface.getDescription());
            list.add(repoJSON);
        }
    }
    return list.toString();
}
Also used : JSONObject(org.json.simple.JSONObject) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) JSONArray(org.json.simple.JSONArray)

Example 29 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class MQTTProducerDialog method getImage.

private Image getImage() {
    PluginInterface plugin = PluginRegistry.getInstance().getPlugin(StepPluginType.class, stepMeta.getStepMetaInterface());
    String id = plugin.getIds()[0];
    if (id != null) {
        return GUIResource.getInstance().getImagesSteps().get(id).getAsBitmapForSize(shell.getDisplay(), ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
    }
    return null;
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Example 30 with PluginInterface

use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.

the class MySQLBulkLoader method execute.

public boolean execute(MySQLBulkLoaderMeta meta) throws KettleException {
    Runtime rt = Runtime.getRuntime();
    try {
        // 1) Create the FIFO file using the "mkfifo" command...
        // Make sure to log all the possible output, also from STDERR
        // 
        data.fifoFilename = environmentSubstitute(meta.getFifoFileName());
        File fifoFile = new File(data.fifoFilename);
        if (!fifoFile.exists()) {
            // MKFIFO!
            // 
            String mkFifoCmd = "mkfifo " + data.fifoFilename;
            // 
            logBasic(BaseMessages.getString(PKG, "MySQLBulkLoader.Message.CREATINGFIFO", data.dbDescription, mkFifoCmd));
            Process mkFifoProcess = rt.exec(mkFifoCmd);
            StreamLogger errorLogger = new StreamLogger(log, mkFifoProcess.getErrorStream(), "mkFifoError");
            StreamLogger outputLogger = new StreamLogger(log, mkFifoProcess.getInputStream(), "mkFifoOuptut");
            new Thread(errorLogger).start();
            new Thread(outputLogger).start();
            int result = mkFifoProcess.waitFor();
            if (result != 0) {
                throw new Exception(BaseMessages.getString(PKG, "MySQLBulkLoader.Message.ERRORFIFORC", result, mkFifoCmd));
            }
            String chmodCmd = "chmod 666 " + data.fifoFilename;
            logBasic(BaseMessages.getString(PKG, "MySQLBulkLoader.Message.SETTINGPERMISSIONSFIFO", data.dbDescription, chmodCmd));
            Process chmodProcess = rt.exec(chmodCmd);
            errorLogger = new StreamLogger(log, chmodProcess.getErrorStream(), "chmodError");
            outputLogger = new StreamLogger(log, chmodProcess.getInputStream(), "chmodOuptut");
            new Thread(errorLogger).start();
            new Thread(outputLogger).start();
            result = chmodProcess.waitFor();
            if (result != 0) {
                throw new Exception(BaseMessages.getString(PKG, "MySQLBulkLoader.Message.ERRORFIFORC", result, chmodCmd));
            }
        }
        // 2) Make a connection to MySQL for sending SQL commands
        // (Also, we need a clear cache for getting up-to-date target metadata)
        DBCache.getInstance().clear(meta.getDatabaseMeta().getName());
        if (meta.getDatabaseMeta() == null) {
            logError(BaseMessages.getString(PKG, "MySQLBulkLoader.Init.ConnectionMissing", getStepname()));
            return false;
        }
        data.db = new Database(this, meta.getDatabaseMeta());
        data.db.shareVariablesWith(this);
        PluginInterface dbPlugin = PluginRegistry.getInstance().getPlugin(DatabasePluginType.class, meta.getDatabaseMeta().getDatabaseInterface());
        data.dbDescription = (dbPlugin != null) ? dbPlugin.getDescription() : BaseMessages.getString(PKG, "MySQLBulkLoader.UnknownDB");
        // Connect to the database
        if (getTransMeta().isUsingUniqueConnections()) {
            synchronized (getTrans()) {
                data.db.connect(getTrans().getTransactionId(), getPartitionID());
            }
        } else {
            data.db.connect(getPartitionID());
        }
        logBasic(BaseMessages.getString(PKG, "MySQLBulkLoader.Message.CONNECTED", data.dbDescription));
        // 3) Now we are ready to run the load command...
        // 
        executeLoadCommand();
    } catch (Exception ex) {
        throw new KettleException(ex);
    }
    return true;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) StreamLogger(org.pentaho.di.core.util.StreamLogger) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Database(org.pentaho.di.core.database.Database) File(java.io.File) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Aggregations

PluginInterface (org.pentaho.di.core.plugins.PluginInterface)99 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)45 KettleException (org.pentaho.di.core.exception.KettleException)24 ArrayList (java.util.ArrayList)17 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)14 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)12 TransMeta (org.pentaho.di.trans.TransMeta)11 StepMeta (org.pentaho.di.trans.step.StepMeta)11 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)10 Test (org.junit.Test)9 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)9 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)8 Point (org.pentaho.di.core.gui.Point)8 JobMeta (org.pentaho.di.job.JobMeta)8 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)7 TransHopMeta (org.pentaho.di.trans.TransHopMeta)7 TreeItem (org.eclipse.swt.widgets.TreeItem)6 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)6 LongObjectId (org.pentaho.di.repository.LongObjectId)6 ObjectId (org.pentaho.di.repository.ObjectId)6