Search in sources :

Example 1 with BlobItem

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;
}
Also used : BlobItem(com.microsoft.azure.storage.blob.models.BlobItem) ListBlobsOptions(com.microsoft.azure.storage.blob.ListBlobsOptions) ArrayList(java.util.ArrayList) ContainerListBlobFlatSegmentResponse(com.microsoft.azure.storage.blob.models.ContainerListBlobFlatSegmentResponse) BlobFlatListSegment(com.microsoft.azure.storage.blob.models.BlobFlatListSegment)

Example 2 with BlobItem

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);
    }
}
Also used : BlobItem(com.microsoft.azure.storage.blob.models.BlobItem) LockProvider(org.geowebcache.locks.LockProvider) BlobHTTPHeaders(com.microsoft.azure.storage.blob.models.BlobHTTPHeaders) Resource(org.geowebcache.io.Resource) TileRange(org.geowebcache.storage.TileRange) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) BlobItem(com.microsoft.azure.storage.blob.models.BlobItem) Iterators(com.google.common.collect.Iterators) ByteBuffer(java.nio.ByteBuffer) BlobStore(org.geowebcache.storage.BlobStore) Flowable(io.reactivex.Flowable) TileLayerDispatcher(org.geowebcache.layer.TileLayerDispatcher) StorageException(org.geowebcache.storage.StorageException) TileRangeIterator(org.geowebcache.storage.TileRangeIterator) Map(java.util.Map) Objects.isNull(java.util.Objects.isNull) BlobStoreListenerList(org.geowebcache.storage.BlobStoreListenerList) Nullable(javax.annotation.Nullable) DownloadResponse(com.microsoft.azure.storage.blob.DownloadResponse) Properties(java.util.Properties) Iterator(java.util.Iterator) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) AbstractIterator(com.google.common.collect.AbstractIterator) IOException(java.io.IOException) BlobStoreListener(org.geowebcache.storage.BlobStoreListener) Collectors(java.util.stream.Collectors) BlockBlobURL(com.microsoft.azure.storage.blob.BlockBlobURL) CompositeBlobStore(org.geowebcache.storage.CompositeBlobStore) BlobGetPropertiesResponse(com.microsoft.azure.storage.blob.models.BlobGetPropertiesResponse) ByteArrayResource(org.geowebcache.io.ByteArrayResource) RestException(com.microsoft.rest.v2.RestException) IOUtils(org.apache.commons.io.IOUtils) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) MimeException(org.geowebcache.mime.MimeException) MimeType(org.geowebcache.mime.MimeType) ParametersUtils(org.geowebcache.filter.parameters.ParametersUtils) FlowableUtil(com.microsoft.rest.v2.util.FlowableUtil) Optional(java.util.Optional) TileObject(org.geowebcache.storage.TileObject) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) InputStream(java.io.InputStream) TMSKeyBuilder(org.geowebcache.util.TMSKeyBuilder) Optional(java.util.Optional) HashMap(java.util.HashMap) StorageException(org.geowebcache.storage.StorageException)

Example 3 with BlobItem

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());
    }
}
Also used : BlobItem(com.microsoft.azure.storage.blob.models.BlobItem) BlockBlobURL(com.microsoft.azure.storage.blob.BlockBlobURL)

Aggregations

BlobItem (com.microsoft.azure.storage.blob.models.BlobItem)3 BlockBlobURL (com.microsoft.azure.storage.blob.BlockBlobURL)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 AbstractIterator (com.google.common.collect.AbstractIterator)1 Iterators (com.google.common.collect.Iterators)1 DownloadResponse (com.microsoft.azure.storage.blob.DownloadResponse)1 ListBlobsOptions (com.microsoft.azure.storage.blob.ListBlobsOptions)1 BlobFlatListSegment (com.microsoft.azure.storage.blob.models.BlobFlatListSegment)1 BlobGetPropertiesResponse (com.microsoft.azure.storage.blob.models.BlobGetPropertiesResponse)1 BlobHTTPHeaders (com.microsoft.azure.storage.blob.models.BlobHTTPHeaders)1 ContainerListBlobFlatSegmentResponse (com.microsoft.azure.storage.blob.models.ContainerListBlobFlatSegmentResponse)1 RestException (com.microsoft.rest.v2.RestException)1 FlowableUtil (com.microsoft.rest.v2.util.FlowableUtil)1 Flowable (io.reactivex.Flowable)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1