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);
}
}
}
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations