Search in sources :

Example 6 with BlockBlobURL

use of com.microsoft.azure.storage.blob.BlockBlobURL in project geowebcache by GeoWebCache.

the class AzureBlobStore method delete.

@Override
public boolean delete(String layerName) throws StorageException {
    checkNotNull(layerName, "layerName");
    final String metadataKey = keyBuilder.layerMetadata(layerName);
    final String layerPrefix = keyBuilder.forLayer(layerName);
    // this might not be there, tolerant delete
    try {
        BlockBlobURL metadata = client.getBlockBlobURL(metadataKey);
        int statusCode = metadata.delete().blockingGet().statusCode();
        if (!HttpStatus.valueOf(statusCode).is2xxSuccessful()) {
            return false;
        }
    } catch (RestException e) {
        return false;
    }
    boolean layerExists = deleteManager.scheduleAsyncDelete(layerPrefix);
    if (layerExists) {
        listeners.sendLayerDeleted(layerName);
    }
    return layerExists;
}
Also used : BlockBlobURL(com.microsoft.azure.storage.blob.BlockBlobURL) RestException(com.microsoft.rest.v2.RestException)

Example 7 with BlockBlobURL

use of com.microsoft.azure.storage.blob.BlockBlobURL 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

BlockBlobURL (com.microsoft.azure.storage.blob.BlockBlobURL)7 RestException (com.microsoft.rest.v2.RestException)6 StorageException (org.geowebcache.storage.StorageException)5 ByteBuffer (java.nio.ByteBuffer)4 DownloadResponse (com.microsoft.azure.storage.blob.DownloadResponse)2 BlobGetPropertiesResponse (com.microsoft.azure.storage.blob.models.BlobGetPropertiesResponse)2 BlobHTTPHeaders (com.microsoft.azure.storage.blob.models.BlobHTTPHeaders)2 IOException (java.io.IOException)2 ByteArrayResource (org.geowebcache.io.ByteArrayResource)2 BlobItem (com.microsoft.azure.storage.blob.models.BlobItem)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Nullable (javax.annotation.Nullable)1 Resource (org.geowebcache.io.Resource)1 MimeException (org.geowebcache.mime.MimeException)1