use of org.talend.components.azurestorage.blob.helpers.RemoteBlob in project components by Talend.
the class RemoteBlobTest method setUp.
@Before
public void setUp() throws Exception {
remoteBlob = new RemoteBlob("", true);
remoteBlobGet = new RemoteBlobGet("", true, true);
remoteBlobGet2 = new RemoteBlobGet("", true);
}
use of org.talend.components.azurestorage.blob.helpers.RemoteBlob in project components by Talend.
the class AzureStorageSource method getRemoteBlobs.
public List<RemoteBlob> getRemoteBlobs() {
List<RemoteBlob> remoteBlobs = new ArrayList<RemoteBlob>();
if (!(this.properties instanceof AzureStorageBlobProperties))
return null;
AzureStorageBlobProperties p = (AzureStorageBlobProperties) properties;
ValidationResult vr = p.remoteBlobs.getValidationResult();
if (vr.getStatus().equals(Result.ERROR)) {
throw new IllegalArgumentException(vr.getMessage());
}
for (int idx = 0; idx < p.remoteBlobs.prefix.getValue().size(); idx++) {
String prefix = (p.remoteBlobs.prefix.getValue().get(idx) != null) ? p.remoteBlobs.prefix.getValue().get(idx) : "";
Boolean include = (p.remoteBlobs.include.getValue().get(idx) != null) ? p.remoteBlobs.include.getValue().get(idx) : false;
remoteBlobs.add(new RemoteBlob(prefix, include));
}
return remoteBlobs;
}
use of org.talend.components.azurestorage.blob.helpers.RemoteBlob in project components by Talend.
the class AzureStorageListReader method start.
@Override
public boolean start() throws IOException {
String mycontainer = properties.container.getValue();
List<CloudBlob> blobs = new ArrayList<>();
// build a list with remote blobs to fetch
List<RemoteBlob> remoteBlobs = ((AzureStorageSource) getCurrentSource()).getRemoteBlobs();
try {
for (RemoteBlob rmtb : remoteBlobs) {
for (ListBlobItem blob : azureStorageBlobService.listBlobs(mycontainer, rmtb.prefix, rmtb.include)) {
if (blob instanceof CloudBlob) {
blobs.add((CloudBlob) blob);
}
}
}
startable = !blobs.isEmpty();
blobsIterator = blobs.iterator();
} catch (StorageException | URISyntaxException | InvalidKeyException e) {
LOGGER.error(e.getLocalizedMessage());
if (properties.dieOnError.getValue()) {
throw new ComponentException(e);
}
}
if (startable) {
dataCount++;
currentBlob = blobsIterator.next();
IndexedRecord dataRecord = new GenericData.Record(properties.schema.schema.getValue());
dataRecord.put(0, currentBlob.getName());
Schema rootSchema = RootSchemaUtils.createRootSchema(properties.schema.schema.getValue(), properties.outOfBandSchema);
currentRecord = new GenericData.Record(rootSchema);
currentRecord.put(0, dataRecord);
currentRecord.put(1, dataRecord);
}
return startable;
}
use of org.talend.components.azurestorage.blob.helpers.RemoteBlob in project components by Talend.
the class AzureStorageDeleteRuntime method createRemoteBlobFilter.
/**
* Create remote blob table used in filtering remote blob
*/
private List<RemoteBlob> createRemoteBlobFilter() {
List<RemoteBlob> remoteBlobs = new ArrayList<RemoteBlob>();
for (int idx = 0; idx < this.remoteBlobsTable.prefix.getValue().size(); idx++) {
String prefix = "";
boolean include = false;
if (this.remoteBlobsTable.prefix.getValue().get(idx) != null) {
prefix = this.remoteBlobsTable.prefix.getValue().get(idx);
}
if (remoteBlobsTable.include.getValue().get(idx) != null) {
include = remoteBlobsTable.include.getValue().get(idx);
}
remoteBlobs.add(new RemoteBlob(prefix, include));
}
return remoteBlobs;
}
Aggregations