Search in sources :

Example 6 with RestException

use of com.microsoft.rest.v2.RestException 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)

Aggregations

BlockBlobURL (com.microsoft.azure.storage.blob.BlockBlobURL)6 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 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