Search in sources :

Example 46 with ComponentException

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());
    }
}
Also used : ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) IOException(java.io.IOException) URL(java.net.URL)

Example 47 with ComponentException

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;
}
Also used : ComponentWizard(org.talend.components.api.wizard.ComponentWizard) ComponentException(org.talend.components.api.exception.ComponentException) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition)

Example 48 with ComponentException

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));
    }
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition)

Example 49 with ComponentException

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
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) Schema(org.apache.avro.Schema) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property)

Example 50 with ComponentException

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;
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) Schema(org.apache.avro.Schema) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property)

Aggregations

ComponentException (org.talend.components.api.exception.ComponentException)101 URL (java.net.URL)32 MalformedURLException (java.net.MalformedURLException)30 JarRuntimeInfo (org.talend.components.api.component.runtime.JarRuntimeInfo)27 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)17 InvalidKeyException (java.security.InvalidKeyException)14 Schema (org.apache.avro.Schema)14 URISyntaxException (java.net.URISyntaxException)12 StorageException (com.microsoft.azure.storage.StorageException)11 NamedThing (org.talend.daikon.NamedThing)11 ValidationResult (org.talend.daikon.properties.ValidationResult)10 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)10 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 Test (org.junit.Test)8 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)8 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)6 GeneralSecurityException (java.security.GeneralSecurityException)5 JDBCSource (org.talend.components.jdbc.runtime.JDBCSource)5 TJDBCInputDefinition (org.talend.components.jdbc.tjdbcinput.TJDBCInputDefinition)5