use of com.azure.storage.blob.models.BlobContainerItem in project ats-framework by Axway.
the class BlobStorageOperations method listContainers.
private PagedIterable<BlobContainerItem> listContainers(String containerNamePrefix, long retrieveTimeoutSeconds, boolean retrieveMetadata) {
try {
StringBuilder message = new StringBuilder();
message.append("Listing");
BlobContainerListDetails bcld = new BlobContainerListDetails();
ListBlobContainersOptions lbco = new ListBlobContainersOptions();
message.append(" containers");
if (containerNamePrefix != null && !containerNamePrefix.isEmpty()) {
message.append(" with prefix '" + containerNamePrefix + "'");
lbco.setPrefix(containerNamePrefix);
}
if (log.isInfoEnabled()) {
message.append(" ...");
log.info(message.toString());
}
bcld.setRetrieveMetadata(retrieveMetadata);
lbco.setDetails(bcld);
if (retrieveTimeoutSeconds <= 0) {
// just a little less than too much
retrieveTimeoutSeconds = Integer.MAX_VALUE / 2;
}
PagedIterable<BlobContainerItem> blobContainers = serviceClient.listBlobContainers(lbco, Duration.ofSeconds(retrieveTimeoutSeconds));
log.info("Successfully listed " + blobContainers.stream().count() + " containers.");
return blobContainers;
} catch (Exception e) {
throw new AtsBlobStorageException("Could not list containers " + (!StringUtils.isNullOrEmpty(containerNamePrefix) ? "with prefix '" + containerNamePrefix + "'" : "") + " in " + retrieveTimeoutSeconds + " seconds", e);
}
}
Aggregations