use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class S3OutputDefinition method getRuntimeInfo.
@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
assertEngineCompatibility(engine);
assertConnectorTopologyCompatibility(connectorTopology);
try {
switch(engine) {
case DI:
return new JarRuntimeInfo(new URL(SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_DI_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(SimpleFileIOComponentFamilyDefinition.MAVEN_GROUP_ID, SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_DI_RUNTIME_ARTIFACT_ID), DI_RUNTIME);
case BEAM:
default:
return new JarRuntimeInfo(new URL(SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(SimpleFileIOComponentFamilyDefinition.MAVEN_GROUP_ID, SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_ARTIFACT_ID), RUNTIME);
}
} catch (MalformedURLException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class ElasticsearchOutputDefinition method getRuntimeInfo.
@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
assertEngineCompatibility(engine);
assertConnectorTopologyCompatibility(connectorTopology);
try {
switch(((ElasticsearchOutputProperties) properties).getDatasetProperties().getDatastoreProperties().version.getValue()) {
case V_2_4:
default:
return new JarRuntimeInfo(new URL(MAVEN_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(MAVEN_GROUP_ID, MAVEN_RUNTIME_ARTIFACT_ID), RUNTIME_2_4);
}
} catch (MalformedURLException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class SimpleFileIOOutputDefinition method getRuntimeInfo.
@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
assertEngineCompatibility(engine);
assertConnectorTopologyCompatibility(connectorTopology);
try {
return new JarRuntimeInfo(new URL(SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(SimpleFileIOComponentFamilyDefinition.MAVEN_GROUP_ID, SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_ARTIFACT_ID), RUNTIME);
} catch (MalformedURLException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class MarketoSOAPClient method getLeadChanges.
@Override
public MarketoRecordResult getLeadChanges(TMarketoInputProperties parameters, String offset) {
Schema schema = parameters.schemaInput.schema.getValue();
Map<String, String> mappings = parameters.mappingInput.getNameMappingsForMarketo();
int bSize = parameters.batchSize.getValue() > 100 ? 100 : parameters.batchSize.getValue();
String sOldest = parameters.oldestCreateDate.getValue();
String sLatest = parameters.latestCreateDate.getValue();
LOG.debug("LeadChanges - from {} to {}.", sOldest, sLatest);
//
// Create Request
//
ParamsGetLeadChanges request = new ParamsGetLeadChanges();
LastUpdateAtSelector leadSelector = new LastUpdateAtSelector();
try {
Date oldest = MarketoUtils.parseDateString(sOldest);
Date latest = MarketoUtils.parseDateString(sLatest);
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(latest);
DatatypeFactory factory = newInstance();
JAXBElement<XMLGregorianCalendar> until = objectFactory.createLastUpdateAtSelectorLatestUpdatedAt(factory.newXMLGregorianCalendar(gc));
GregorianCalendar since = new GregorianCalendar();
since.setTime(oldest);
leadSelector.setOldestUpdatedAt(factory.newXMLGregorianCalendar(since));
leadSelector.setLatestUpdatedAt(until);
request.setLeadSelector(leadSelector);
JAXBElement<XMLGregorianCalendar> oldestCreateAtValue = objectFactory.createStreamPositionOldestCreatedAt(factory.newXMLGregorianCalendar(since));
StreamPosition sp = new StreamPosition();
sp.setOldestCreatedAt(oldestCreateAtValue);
if (offset != null && !offset.isEmpty()) {
sp.setOffset(objectFactory.createStreamPositionOffset(offset));
}
request.setStartPosition(sp);
} catch (ParseException | DatatypeConfigurationException e) {
LOG.error("Error for LastUpdateAtSelector : {}.", e.getMessage());
throw new ComponentException(e);
}
// attributes
ArrayOfString attributes = new ArrayOfString();
for (String s : mappings.values()) {
attributes.getStringItems().add(s);
}
// Activity filter
ActivityTypeFilter filter = new ActivityTypeFilter();
if (parameters.setIncludeTypes.getValue()) {
ArrayOfActivityType includes = new ArrayOfActivityType();
for (String a : parameters.includeTypes.type.getValue()) {
includes.getActivityTypes().add(fromValue(a));
}
filter.setIncludeTypes(includes);
}
if (parameters.setExcludeTypes.getValue()) {
ArrayOfActivityType excludes = new ArrayOfActivityType();
for (String a : parameters.excludeTypes.type.getValue()) {
excludes.getActivityTypes().add(fromValue(a));
}
filter.setExcludeTypes(excludes);
}
JAXBElement<ActivityTypeFilter> typeFilter = objectFactory.createParamsGetLeadActivityActivityFilter(filter);
request.setActivityFilter(typeFilter);
// batch size
JAXBElement<Integer> batchSize = objectFactory.createParamsGetMultipleLeadsBatchSize(bSize);
request.setBatchSize(batchSize);
//
//
// Request execution
//
SuccessGetLeadChanges result = null;
MarketoRecordResult mkto = new MarketoRecordResult();
try {
result = getPort().getLeadChanges(request, header);
mkto.setSuccess(true);
} catch (Exception e) {
LOG.error("getLeadChanges error: {}.", e.getMessage());
mkto.setSuccess(false);
mkto.setRecordCount(0);
mkto.setRemainCount(0);
mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage())));
return mkto;
}
if (result == null || result.getResult().getReturnCount() == 0) {
LOG.debug(MESSAGE_REQUEST_RETURNED_0_MATCHING_LEADS);
mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, MESSAGE_NO_LEADS_FOUND)));
return mkto;
}
String streamPos = result.getResult().getNewStartPosition().getOffset().getValue();
int recordCount = result.getResult().getReturnCount();
int remainCount = result.getResult().getRemainingCount();
// Process results
List<IndexedRecord> results = convertLeadChangeRecords(result.getResult().getLeadChangeRecordList().getValue().getLeadChangeRecords(), schema, mappings);
mkto.setRecordCount(recordCount);
mkto.setRemainCount(remainCount);
mkto.setStreamPosition(streamPos);
mkto.setRecords(results);
return mkto;
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class GoogleDrivePutRuntime method putFile.
private void putFile(RuntimeContainer container) {
try {
String destinationFolderId = properties.destinationFolderAccessMethod.getValue().equals(AccessMethod.Id) ? properties.destinationFolder.getValue() : getDriveUtils().getFolderId(properties.destinationFolder.getValue(), false);
GoogleDrivePutParameters p = new GoogleDrivePutParameters(destinationFolderId, properties.fileName.getValue(), properties.overwrite.getValue(), properties.localFilePath.getValue());
sentFile = getDriveUtils().putResource(p);
} catch (IOException | GeneralSecurityException e) {
LOG.error(e.getLocalizedMessage());
throw new ComponentException(e);
}
}
Aggregations