Search in sources :

Example 1 with KettlePluginException

use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.

the class KettleVariablesList method init.

public static void init() throws KettleException {
    InputStream inputStream = null;
    try {
        KettleVariablesList variablesList = getInstance();
        inputStream = variablesList.getClass().getResourceAsStream(Const.KETTLE_VARIABLES_FILE);
        if (inputStream == null) {
            inputStream = variablesList.getClass().getResourceAsStream("/" + Const.KETTLE_VARIABLES_FILE);
        }
        if (inputStream == null) {
            throw new KettlePluginException("Unable to find standard kettle variables definition file: " + Const.KETTLE_VARIABLES_FILE);
        }
        Document doc = XMLHandler.loadXMLFile(inputStream, null, false, false);
        Node varsNode = XMLHandler.getSubNode(doc, "kettle-variables");
        int nrVars = XMLHandler.countNodes(varsNode, "kettle-variable");
        for (int i = 0; i < nrVars; i++) {
            Node varNode = XMLHandler.getSubNodeByNr(varsNode, "kettle-variable", i);
            String description = XMLHandler.getTagValue(varNode, "description");
            String variable = XMLHandler.getTagValue(varNode, "variable");
            String defaultValue = XMLHandler.getTagValue(varNode, "default-value");
            variablesList.getDescriptionMap().put(variable, description);
            variablesList.getDefaultValueMap().put(variable, defaultValue);
        }
    } catch (Exception e) {
        throw new KettleException("Unable to read file '" + Const.KETTLE_VARIABLES_FILE + "'", e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e) {
                // we do not able to close property file will log it
                logger.logDetailed("Unable to close file kettle variables definition file", e);
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) IOException(java.io.IOException) Document(org.w3c.dom.Document) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Example 2 with KettlePluginException

use of org.pentaho.di.core.exception.KettlePluginException 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 3 with KettlePluginException

use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.

the class YamlInputMeta method getFields.

@Override
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    int i;
    for (i = 0; i < inputFields.length; i++) {
        YamlInputField field = inputFields[i];
        int type = field.getType();
        if (type == ValueMetaInterface.TYPE_NONE) {
            type = ValueMetaInterface.TYPE_STRING;
        }
        String valueName = space.environmentSubstitute(field.getName());
        ValueMetaInterface v;
        try {
            v = ValueMetaFactory.createValueMeta(valueName, type);
        } catch (KettlePluginException e) {
            v = new ValueMetaString(valueName);
        }
        v.setLength(field.getLength());
        v.setPrecision(field.getPrecision());
        v.setOrigin(name);
        v.setConversionMask(field.getFormat());
        v.setDecimalSymbol(field.getDecimalSymbol());
        v.setGroupingSymbol(field.getGroupSymbol());
        v.setCurrencySymbol(field.getCurrencySymbol());
        r.addValueMeta(v);
    }
    if (includeFilename) {
        ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(filenameField));
        v.setLength(250);
        v.setPrecision(-1);
        v.setOrigin(name);
        r.addValueMeta(v);
    }
    if (includeRowNumber) {
        ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
        v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
        v.setOrigin(name);
        r.addValueMeta(v);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 4 with KettlePluginException

use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.

the class RowMetaAndData method addValue.

public void addValue(String valueName, int valueType, Object valueData) {
    ValueMetaInterface v;
    try {
        v = ValueMetaFactory.createValueMeta(valueName, valueType);
    } catch (KettlePluginException e) {
        v = new ValueMetaNone(valueName);
    }
    addValue(v, valueData);
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 5 with KettlePluginException

use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.

the class ExtensionPointIntegrationTest method testExtensionPointMapConcurrency.

@Test
public void testExtensionPointMapConcurrency() throws InterruptedException {
    final LogChannelInterface log = mock(LogChannelInterface.class);
    List<Runnable> parallelTasksList = new ArrayList<>(TOTAL_THREADS_TO_RUN);
    for (int i = 0; i < TOTAL_THREADS_TO_RUN; i++) {
        parallelTasksList.add(() -> {
            KettleExtensionPoint kettleExtensionPoint = getRandomKettleExtensionPoint();
            PluginInterface pluginInterface = PluginRegistry.getInstance().getPlugin(ExtensionPointPluginType.class, "id" + kettleExtensionPoint.id);
            try {
                PluginRegistry.getInstance().removePlugin(ExtensionPointPluginType.class, pluginInterface);
                PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
            } catch (KettlePluginException e) {
                e.printStackTrace();
            } catch (NullPointerException e) {
            // NullPointerException can be thrown if trying to remove a plugin that doesn't exit, discarding occurence
            }
            ExtensionPointMap.getInstance().reInitialize();
            try {
                ExtensionPointMap.getInstance().callExtensionPoint(log, kettleExtensionPoint.id, null);
            } catch (KettleException e) {
                e.printStackTrace();
            }
        });
    }
    assertConcurrent(parallelTasksList);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Test(org.junit.Test)

Aggregations

KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)47 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)23 FileObject (org.apache.commons.vfs2.FileObject)12 Node (org.w3c.dom.Node)11 RowMeta (org.pentaho.di.core.row.RowMeta)10 ValueMetaNone (org.pentaho.di.core.row.value.ValueMetaNone)10 Document (org.w3c.dom.Document)10 ArrayList (java.util.ArrayList)9 KettleStepException (org.pentaho.di.core.exception.KettleStepException)9 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)9 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)9 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)7 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)6 Map (java.util.Map)4 KettleException (org.pentaho.di.core.exception.KettleException)4 PluginFolderInterface (org.pentaho.di.core.plugins.PluginFolderInterface)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 Annotation (java.lang.annotation.Annotation)3 URLClassLoader (java.net.URLClassLoader)3