use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class AzureStorageGetRuntime method download.
private void download(RuntimeContainer runtimeContainer) {
FileOutputStream fos = null;
try {
List<RemoteBlobGet> remoteBlobs = createRemoteBlobsGet();
for (RemoteBlobGet rmtb : remoteBlobs) {
for (ListBlobItem blob : azureStorageBlobService.listBlobs(containerName, rmtb.prefix, rmtb.include)) {
if (blob instanceof CloudBlob) {
// TODO - Action when create is false and include is true ???
if (rmtb.create) {
new File(localFolder + "/" + ((CloudBlob) blob).getName()).getParentFile().mkdirs();
}
fos = new FileOutputStream(localFolder + "/" + ((CloudBlob) blob).getName());
azureStorageBlobService.download((CloudBlob) blob, fos);
}
}
}
} catch (StorageException | URISyntaxException | FileNotFoundException | InvalidKeyException e) {
LOGGER.error(e.getLocalizedMessage());
if (dieOnError) {
throw new ComponentException(e);
}
} finally {
try {
fos.close();
} catch (Exception e) {
// ignore
}
}
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class AzureStorageQueueCreateRuntime method createAzureQueue.
private boolean createAzureQueue(RuntimeContainer container) {
Boolean createResult = false;
try {
LOGGER.debug(messages.getMessage("debug.QueuePrecreate", queueName));
createResult = queueService.createQueueIfNotExists(queueName);
if (!createResult) {
LOGGER.warn(messages.getMessage("warn.QueueExist", queueName));
}
} catch (InvalidKeyException | URISyntaxException | StorageException e) {
LOGGER.error(e.getLocalizedMessage());
if (dieOnError) {
throw new ComponentException(e);
}
}
return createResult;
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class AzureStorageQueueListReader method start.
@Override
public boolean start() throws IOException {
try {
queues = queueService.listQueues().iterator();
startable = queues.hasNext();
if (startable) {
current = queues.next();
dataCount++;
}
} catch (InvalidKeyException | URISyntaxException e) {
LOGGER.error(e.getLocalizedMessage());
if (dieOnError) {
throw new ComponentException(e);
}
}
return startable;
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class AzureStorageQueuePurgeRuntime method purgeAzureQueue.
private boolean purgeAzureQueue(RuntimeContainer container) {
Boolean purgeResult = false;
try {
int dataCount = (int) queueService.getApproximateMessageCount(queueName);
LOGGER.debug(messages.getMessage("debug.Purgeing", dataCount, queueName));
queueService.clear(queueName);
purgeResult = true;
} catch (InvalidKeyException | URISyntaxException | StorageException e) {
LOGGER.error(e.getLocalizedMessage());
if (dieOnError) {
throw new ComponentException(e);
}
}
return purgeResult;
}
use of org.talend.components.api.exception.ComponentException in project components by Talend.
the class BigQueryDatasetProperties method beforeBqDataset.
public ValidationResult beforeBqDataset() {
BigQueryDatasetDefinition definition = new BigQueryDatasetDefinition();
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
IBigQueryDatasetRuntime runtime = (IBigQueryDatasetRuntime) sandboxedInstance.getInstance();
runtime.initialize(null, this);
List<NamedThing> datasets = new ArrayList<>();
for (String dataset : runtime.listDatasets()) {
datasets.add(new SimpleNamedThing(dataset, dataset));
}
bqDataset.setPossibleValues(datasets);
return ValidationResult.OK;
} catch (Exception e) {
return new ValidationResult(new ComponentException(e));
}
}
Aggregations