Search in sources :

Example 36 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class HadoopClusterConfigurationReader method initConfigurator.

private void initConfigurator() {
    initBuilder();
    try {
        builder = builder.withUrl(new URL(properties.url.getValue()));
        if (properties.basicAuth.useAuth.getValue()) {
            this.builder = this.builder.withUsernamePassword(properties.basicAuth.userId.getValue(), properties.basicAuth.password.getValue());
        }
        if (properties.ssl.useSsl.getValue()) {
            String filePath = properties.ssl.trustStorePath.getValue();
            String type = properties.ssl.trustStoreType.getValue().toString();
            String pwd = properties.ssl.trustStorePassword.getValue();
            this.builder = this.builder.withTrustManagers(getTrustManagers(filePath, type, pwd));
        }
        configurator = this.builder.build();
    } catch (Exception e) {
        throw new ComponentException(e);
    }
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) URL(java.net.URL) ComponentException(org.talend.components.api.exception.ComponentException) IOException(java.io.IOException) KeyStoreException(java.security.KeyStoreException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoSuchElementException(java.util.NoSuchElementException)

Example 37 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class HadoopClusterConfigurationInputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(connectorTopology);
    try {
        HadoopClusterConfigurationInputProperties inputProperties = (HadoopClusterConfigurationInputProperties) properties;
        switch(inputProperties.clusterManagerType.getValue()) {
            case AMBARI:
                return new JarRuntimeInfo(new URL(HadoopClusterFamilyDefinition.MAVEN_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(HadoopClusterFamilyDefinition.MAVEN_GROUP_ID, HadoopClusterFamilyDefinition.MAVEN_RUNTIME_ARTIFACT_ID), RUNTIME_AMBARI);
            case CLOUDERA_MANAGER:
                return new JarRuntimeInfo(new URL(HadoopClusterFamilyDefinition.MAVEN_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(HadoopClusterFamilyDefinition.MAVEN_GROUP_ID, HadoopClusterFamilyDefinition.MAVEN_RUNTIME_ARTIFACT_ID), RUNTIME_CM);
            default:
                throw new ComponentException(new RuntimeException("Do not support"));
        }
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Example 38 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class HadoopAmbariClusterService method getConfFileContent.

@Override
public String getConfFileContent(String confFileName) {
    Configuration conf = confs.get(confFileName);
    if (conf == null) {
        return null;
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        conf.writeXml(baos);
    } catch (IOException e) {
        throw new ComponentException(e);
    }
    try {
        return baos.toString("UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new ComponentException(e);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ComponentException(org.talend.components.api.exception.ComponentException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 39 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class JDBCTableSelectionModule method beforeTablename.

public ValidationResult beforeTablename() throws IOException {
    JdbcRuntimeInfo jdbcRuntimeInfo = new JdbcRuntimeInfo(connection, "org.talend.components.jdbc.runtime.JDBCSource");
    try (SandboxedInstance sandboxI = RuntimeUtil.createRuntimeClass(jdbcRuntimeInfo, connection.getClass().getClassLoader())) {
        SourceOrSink ss = (SourceOrSink) sandboxI.getInstance();
        ss.initialize(null, (ComponentProperties) connection);
        List<NamedThing> tablenames = ss.getSchemaNames(null);
        tablename.setPossibleNamedThingValues(tablenames);
    } catch (ComponentException ex) {
        return ex.getValidationResult();
    }
    return ValidationResult.OK;
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) SourceOrSink(org.talend.components.api.component.runtime.SourceOrSink) JdbcRuntimeInfo(org.talend.components.jdbc.JdbcRuntimeInfo) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing)

Example 40 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class NetSuiteDatasetRuntimeImpl method getSchemaForRecordRef.

public Schema getSchemaForRecordRef(String typeName) {
    try {
        // Get info for target record type
        final RecordTypeInfo referencedRecordTypeInfo = metaDataSource.getRecordType(typeName);
        final RefType refType = referencedRecordTypeInfo.getRefType();
        // Get type info for record ref
        final TypeDesc typeDesc = metaDataSource.getTypeInfo(refType.getTypeName());
        List<FieldDesc> fieldDescList = new ArrayList<>(typeDesc.getFields());
        // Sort in alphabetical order
        Collections.sort(fieldDescList, FieldDescComparator.INSTANCE);
        Schema schema = inferSchemaForType(typeDesc.getTypeName(), fieldDescList);
        augmentSchemaWithCustomMetaData(metaDataSource, schema, referencedRecordTypeInfo, null);
        return schema;
    } catch (NetSuiteException e) {
        throw new ComponentException(e);
    }
}
Also used : CustomFieldRefType(org.talend.components.netsuite.client.model.customfield.CustomFieldRefType) RefType(org.talend.components.netsuite.client.model.RefType) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) Schema(org.apache.avro.Schema) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) FieldDesc(org.talend.components.netsuite.client.model.FieldDesc)

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