use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class SimpleRuntimeInfo method getMavenUrlDependencies.
@Override
public List<URL> getMavenUrlDependencies() {
DependenciesReader dependenciesReader = new DependenciesReader(depTxtPath);
try {
Set<String> dependencies = dependenciesReader.getDependencies(classloader);
// convert the string to URL
List<URL> result = new ArrayList<>(dependencies.size());
for (String urlString : dependencies) {
result.add(new URL(urlString));
}
return result;
} catch (IOException e) {
throw new ComponentException(ComponentsApiErrorCode.COMPUTE_DEPENDENCIES_FAILED, e, ExceptionContext.withBuilder().put("path", dependenciesReader.getDependencyFilePath()).build());
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class ComponentServiceImpl method getComponentWizard.
@Override
public ComponentWizard getComponentWizard(String name, String location) {
Map<String, ComponentWizardDefinition> definitionMapByType = definitionRegistry.getDefinitionsMapByType(ComponentWizardDefinition.class);
if (definitionMapByType.isEmpty()) {
throw TalendRuntimeException.createUnexpectedException("fails to retrieve any Wizard definitions.");
}
ComponentWizardDefinition wizardDefinition = definitionMapByType.get(name);
if (wizardDefinition == null) {
// $NON-NLS-1$
throw new ComponentException(ComponentsApiErrorCode.WRONG_WIZARD_NAME, ExceptionContext.build().put("name", name));
}
ComponentWizard wizard = wizardDefinition.createWizard(location);
return wizard;
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class ComponentServiceImpl method getWizardPngImage.
@Override
public InputStream getWizardPngImage(String wizardName, WizardImageType imageType) {
Map<String, ComponentWizardDefinition> wizardsDefs = definitionRegistry.getDefinitionsMapByType(ComponentWizardDefinition.class);
if (wizardsDefs.isEmpty()) {
throw TalendRuntimeException.createUnexpectedException("fails to retrieve any Wizard defintions.");
}
ComponentWizardDefinition wizardDefinition = wizardsDefs.get(wizardName);
if (wizardDefinition != null) {
return getImageStream(wizardDefinition, wizardDefinition.getPngImagePath(imageType));
} else {
throw new ComponentException(ComponentsApiErrorCode.WRONG_WIZARD_NAME, // $NON-NLS-1$
ExceptionContext.build().put("name", wizardName));
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class FixedConnectorsComponentProperties method setConnectedSchema.
@SuppressWarnings("unchecked")
@Override
public void setConnectedSchema(Connector connector, Schema schema, boolean isOutputConnection) {
if (connector instanceof PropertyPathConnector) {
NamedThing property = getProperty(((PropertyPathConnector) connector).getPropertyPath());
if (property != null) {
if (property instanceof SchemaProperties) {
SchemaProperties schemaProperties = (SchemaProperties) property;
schemaProperties.schema.setValue(schema);
} else if (property instanceof Property) {
((Property<Schema>) property).setValue(schema);
}
} else {
// else path not found so throw exception
throw new ComponentException(ComponentsErrorCode.WRONG_CONNECTOR, ExceptionContext.build().put("properties", this.getClass().getCanonicalName()));
}
}
// not a connector handled by this class
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class FixedConnectorsComponentProperties method getSchema.
/**
* This default implementation uses {@link PropertyPathConnector} to find the SchemaProperties or Property of type
* Schema instances avaialble in this Object. It return null if none found
*/
@SuppressWarnings("unchecked")
@Override
public Schema getSchema(Connector connector, boolean isOutputConnection) {
if (connector instanceof PropertyPathConnector) {
NamedThing property = getProperty(((PropertyPathConnector) connector).getPropertyPath());
if (property != null) {
Property<Schema> schemaProp = null;
if (property instanceof SchemaProperties) {
SchemaProperties schemaProperties = (SchemaProperties) property;
schemaProp = schemaProperties.schema;
} else if (property instanceof Property) {
schemaProp = (Property<Schema>) property;
}
return schemaProp != null ? schemaProp.getValue() : null;
} else {
// else path not found so throw exception
throw new ComponentException(ComponentsErrorCode.WRONG_CONNECTOR, ExceptionContext.build().put("properties", this.getClass().getCanonicalName()));
}
}
// else not a connector handled by this class so return null
return null;
}
Aggregations