use of com.microsoft.azure.storage.blob.models.BlobItem in project geowebcache by GeoWebCache.
the class AzureClient method listBlobs.
public List<BlobItem> listBlobs(String prefix, Integer maxResults) {
ContainerListBlobFlatSegmentResponse response = container.listBlobsFlatSegment(null, new ListBlobsOptions().withPrefix(prefix).withMaxResults(maxResults)).blockingGet();
BlobFlatListSegment segment = response.body().segment();
List<BlobItem> items = new ArrayList<>();
if (segment != null) {
items.addAll(segment.blobItems());
}
return items;
}
use of com.microsoft.azure.storage.blob.models.BlobItem in project geowebcache by GeoWebCache.
the class AzureBlobStore method getParametersMapping.
@Override
public Map<String, Optional<Map<String, String>>> getParametersMapping(String layerName) {
// going big, with MAX_VALUE, since at the end everything must be held in memory anyways
List<BlobItem> items = client.listBlobs(keyBuilder.parametersMetadataPrefix(layerName), Integer.MAX_VALUE);
Map<String, Optional<Map<String, String>>> result = new HashMap<>();
try {
for (BlobItem item : items) {
Map<String, String> properties = client.getProperties(item.name()).entrySet().stream().collect(Collectors.toMap(e -> (String) e.getKey(), e -> (String) e.getValue()));
result.put(ParametersUtils.getId(properties), Optional.of(properties));
}
return result;
} catch (StorageException e) {
throw new RuntimeException("Failed to retrieve properties mappings", e);
}
}
use of com.microsoft.azure.storage.blob.models.BlobItem in project geowebcache by GeoWebCache.
the class TemporaryAzureFolder method delete.
public void delete() {
checkState(isConfigured(), "client not configured.");
if (temporaryPrefix == null) {
return;
}
List<BlobItem> blobs = client.listBlobs(temporaryPrefix, Integer.MAX_VALUE);
for (BlobItem blob : blobs) {
BlockBlobURL blockBlobURL = client.getBlockBlobURL(blob.name());
int status = blockBlobURL.delete().blockingGet().statusCode();
assertTrue("Expected success but got " + status + " while deleting " + blob.name(), HttpStatus.valueOf(status).is2xxSuccessful());
}
}
Aggregations