Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ADLS Error Mapping #6753

Merged
merged 14 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sdk/storage/azure-storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log azure-storage-file-datalake

## Version XXXX-X-X-beta.X (XXXX-XX-XX)
## Version XX.X.X-beta.X (XXXX-XX-XX)
- Added SAS generation methods on clients to improve discoverability and convenience of sas.
- Mapped StorageErrorException and BlobStorageException to DataLakeStorageException.
- Added support for exists method on FileClients and DirectoryClients

## Version 12.0.0-beta.7 (2019-12-04)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.azure.storage.file.datalake.implementation.models.LeaseAccessConditions;
import com.azure.storage.file.datalake.implementation.models.ModifiedAccessConditions;
import com.azure.storage.file.datalake.implementation.models.PathResourceType;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.DownloadRetryOptions;
import com.azure.storage.file.datalake.models.FileRange;
Expand Down Expand Up @@ -328,7 +329,8 @@ public Mono<FileReadAsyncResponse> readWithResponse(FileRange range, DownloadRet
try {
return blockBlobAsyncClient.downloadWithResponse(Transforms.toBlobRange(range),
Transforms.toBlobDownloadRetryOptions(options), Transforms.toBlobRequestConditions(requestConditions),
getRangeContentMd5).map(Transforms::toFileReadAsyncResponse);
getRangeContentMd5).map(Transforms::toFileReadAsyncResponse)
.onErrorMap(DataLakeImplUtils::transformBlobStorageException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.azure.storage.blob.specialized.BlockBlobClient;
import com.azure.storage.common.Utility;
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.DownloadRetryOptions;
import com.azure.storage.file.datalake.models.FileRange;
Expand Down Expand Up @@ -276,10 +277,12 @@ public void read(OutputStream stream) {
*/
public FileReadResponse readWithResponse(OutputStream stream, FileRange range, DownloadRetryOptions options,
DataLakeRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context) {
BlobDownloadResponse response = blockBlobClient.downloadWithResponse(stream, Transforms.toBlobRange(range),
Transforms.toBlobDownloadRetryOptions(options), Transforms.toBlobRequestConditions(requestConditions),
getRangeContentMd5, timeout, context);
return Transforms.toFileReadResponse(response);
return DataLakeImplUtils.returnOrConvertException(() -> {
BlobDownloadResponse response = blockBlobClient.downloadWithResponse(stream, Transforms.toBlobRange(range),
Transforms.toBlobDownloadRetryOptions(options), Transforms.toBlobRequestConditions(requestConditions),
getRangeContentMd5, timeout, context);
return Transforms.toFileReadResponse(response);
}, logger);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.azure.storage.file.datalake.implementation.DataLakeStorageClientImpl;
import com.azure.storage.file.datalake.implementation.models.FileSystemsListPathsResponse;
import com.azure.storage.file.datalake.implementation.models.Path;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.DataLakeSignedIdentifier;
import com.azure.storage.file.datalake.models.FileSystemAccessPolicies;
Expand Down Expand Up @@ -241,7 +242,8 @@ public Mono<Void> create() {
*/
public Mono<Response<Void>> createWithResponse(Map<String, String> metadata, PublicAccessType accessType) {
try {
return blobContainerAsyncClient.createWithResponse(metadata, Transforms.toBlobPublicAccessType(accessType));
return blobContainerAsyncClient.createWithResponse(metadata, Transforms.toBlobPublicAccessType(accessType))
.onErrorMap(DataLakeImplUtils::transformBlobStorageException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -283,7 +285,8 @@ public Mono<Void> delete() {
public Mono<Response<Void>> deleteWithResponse(DataLakeRequestConditions requestConditions) {
try {
return blobContainerAsyncClient.deleteWithResponse(
Transforms.toBlobRequestConditions(requestConditions));
Transforms.toBlobRequestConditions(requestConditions))
.onErrorMap(DataLakeImplUtils::transformBlobStorageException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -322,6 +325,7 @@ public Mono<FileSystemProperties> getProperties() {
public Mono<Response<FileSystemProperties>> getPropertiesWithResponse(String leaseId) {
try {
return blobContainerAsyncClient.getPropertiesWithResponse(leaseId)
.onErrorMap(DataLakeImplUtils::transformBlobStorageException)
.map(response -> new SimpleResponse<>(response,
Transforms.toFileSystemProperties(response.getValue())));
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -368,7 +372,8 @@ public Mono<Response<Void>> setMetadataWithResponse(Map<String, String> metadata
DataLakeRequestConditions requestConditions) {
try {
return blobContainerAsyncClient.setMetadataWithResponse(metadata,
Transforms.toBlobRequestConditions(requestConditions));
Transforms.toBlobRequestConditions(requestConditions))
.onErrorMap(DataLakeImplUtils::transformBlobStorageException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -664,7 +669,8 @@ public Mono<Response<Void>> setAccessPolicyWithResponse(PublicAccessType accessT
List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions) {
try {
return blobContainerAsyncClient.setAccessPolicyWithResponse(Transforms.toBlobPublicAccessType(accessType),
Transforms.toBlobIdentifierList(identifiers), Transforms.toBlobRequestConditions(requestConditions));
Transforms.toBlobIdentifierList(identifiers), Transforms.toBlobRequestConditions(requestConditions))
.onErrorMap(DataLakeImplUtils::transformBlobStorageException);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -704,6 +710,7 @@ public Mono<FileSystemAccessPolicies> getAccessPolicy() {
public Mono<Response<FileSystemAccessPolicies>> getAccessPolicyWithResponse(String leaseId) {
try {
return blobContainerAsyncClient.getAccessPolicyWithResponse(leaseId)
.onErrorMap(DataLakeImplUtils::transformBlobStorageException)
.map(response -> new SimpleResponse<>(response,
Transforms.toFileSystemAccessPolicies(response.getValue())));
} catch (RuntimeException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.azure.storage.blob.models.BlobContainerAccessPolicies;
import com.azure.storage.blob.models.BlobContainerProperties;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.DataLakeSignedIdentifier;
import com.azure.storage.file.datalake.models.FileSystemAccessPolicies;
Expand Down Expand Up @@ -195,8 +196,9 @@ public void create() {
*/
public Response<Void> createWithResponse(Map<String, String> metadata, PublicAccessType accessType,
Duration timeout, Context context) {
return blobContainerClient.createWithResponse(metadata, Transforms.toBlobPublicAccessType(accessType), timeout,
context);
return DataLakeImplUtils.returnOrConvertException(() ->
blobContainerClient.createWithResponse(metadata, Transforms.toBlobPublicAccessType(accessType), timeout,
context), logger);
}

/**
Expand Down Expand Up @@ -228,8 +230,9 @@ public void delete() {
*/
public Response<Void> deleteWithResponse(DataLakeRequestConditions requestConditions, Duration timeout,
Context context) {
return blobContainerClient.deleteWithResponse(Transforms.toBlobRequestConditions(requestConditions),
timeout, context);
return DataLakeImplUtils.returnOrConvertException(() ->
blobContainerClient.deleteWithResponse(Transforms.toBlobRequestConditions(requestConditions), timeout,
context), logger);
}

/**
Expand Down Expand Up @@ -260,9 +263,11 @@ public FileSystemProperties getProperties() {
* @return A response containing the file system properties.
*/
public Response<FileSystemProperties> getPropertiesWithResponse(String leaseId, Duration timeout, Context context) {
Response<BlobContainerProperties> response = blobContainerClient.getPropertiesWithResponse(leaseId, timeout,
context);
return new SimpleResponse<>(response, Transforms.toFileSystemProperties(response.getValue()));
return DataLakeImplUtils.returnOrConvertException(() -> {
Response<BlobContainerProperties> response = blobContainerClient.getPropertiesWithResponse(leaseId, timeout,
context);
return new SimpleResponse<>(response, Transforms.toFileSystemProperties(response.getValue()));
}, logger);
}

/**
Expand Down Expand Up @@ -294,8 +299,9 @@ public void setMetadata(Map<String, String> metadata) {
*/
public Response<Void> setMetadataWithResponse(Map<String, String> metadata,
DataLakeRequestConditions requestConditions, Duration timeout, Context context) {
return blobContainerClient.setMetadataWithResponse(metadata,
Transforms.toBlobRequestConditions(requestConditions), timeout, context);
return DataLakeImplUtils.returnOrConvertException(() ->
blobContainerClient.setMetadataWithResponse(metadata, Transforms.toBlobRequestConditions(requestConditions),
timeout, context), logger);
}

/**
Expand Down Expand Up @@ -523,9 +529,11 @@ public FileSystemAccessPolicies getAccessPolicy() {
*/
public Response<FileSystemAccessPolicies> getAccessPolicyWithResponse(String leaseId, Duration timeout,
Context context) {
Response<BlobContainerAccessPolicies> response = blobContainerClient.getAccessPolicyWithResponse(leaseId,
timeout, context);
return new SimpleResponse<>(response, Transforms.toFileSystemAccessPolicies(response.getValue()));
return DataLakeImplUtils.returnOrConvertException(() -> {
Response<BlobContainerAccessPolicies> response = blobContainerClient.getAccessPolicyWithResponse(leaseId,
timeout, context);
return new SimpleResponse<>(response, Transforms.toFileSystemAccessPolicies(response.getValue()));
}, logger);
}

/**
Expand Down Expand Up @@ -575,10 +583,11 @@ public void setAccessPolicy(PublicAccessType accessType, List<DataLakeSignedIden
public Response<Void> setAccessPolicyWithResponse(PublicAccessType accessType,
List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions,
Duration timeout, Context context) {
return blobContainerClient
return DataLakeImplUtils.returnOrConvertException(() ->
blobContainerClient
.setAccessPolicyWithResponse(Transforms.toBlobPublicAccessType(accessType),
Transforms.toBlobIdentifierList(identifiers), Transforms.toBlobRequestConditions(requestConditions),
timeout, context);
timeout, context), logger);
}

BlobContainerClient getBlobContainerClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.azure.storage.blob.BlobContainerAsyncClient;
import com.azure.storage.blob.BlobServiceVersion;
import com.azure.storage.blob.BlobUrlParts;
import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.specialized.BlockBlobAsyncClient;
import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder;
import com.azure.storage.common.StorageSharedKeyCredential;
Expand Down Expand Up @@ -324,7 +325,8 @@ public Mono<Response<Void>> setMetadataWithResponse(Map<String, String> metadata
DataLakeRequestConditions requestConditions) {
try {
return this.blockBlobAsyncClient.setMetadataWithResponse(metadata,
Transforms.toBlobRequestConditions(requestConditions));
Transforms.toBlobRequestConditions(requestConditions))
.onErrorMap(ex -> DataLakeImplUtils.transformBlobStorageException((BlobStorageException) ex));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -371,7 +373,8 @@ public Mono<Response<Void>> setHttpHeadersWithResponse(PathHttpHeaders headers,
DataLakeRequestConditions requestConditions) {
try {
return this.blockBlobAsyncClient.setHttpHeadersWithResponse(Transforms.toBlobHttpHeaders(headers),
Transforms.toBlobRequestConditions(requestConditions));
Transforms.toBlobRequestConditions(requestConditions))
.onErrorMap(ex -> DataLakeImplUtils.transformBlobStorageException((BlobStorageException) ex));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand Down Expand Up @@ -413,6 +416,7 @@ public Mono<PathProperties> getProperties() {
public Mono<Response<PathProperties>> getPropertiesWithResponse(DataLakeRequestConditions requestConditions) {
try {
return blockBlobAsyncClient.getPropertiesWithResponse(Transforms.toBlobRequestConditions(requestConditions))
.onErrorMap(ex -> DataLakeImplUtils.transformBlobStorageException((BlobStorageException) ex))
.map(response -> new SimpleResponse<>(response, Transforms.toPathProperties(response.getValue())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.azure.storage.file.datalake.implementation.models.ModifiedAccessConditions;
import com.azure.storage.file.datalake.implementation.models.PathRenameMode;
import com.azure.storage.file.datalake.implementation.models.SourceModifiedAccessConditions;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.PathAccessControl;
import com.azure.storage.file.datalake.models.PathAccessControlEntry;
Expand Down Expand Up @@ -192,8 +193,9 @@ public void setMetadata(Map<String, String> metadata) {
*/
public Response<Void> setMetadataWithResponse(Map<String, String> metadata,
DataLakeRequestConditions requestConditions, Duration timeout, Context context) {
return blockBlobClient.setMetadataWithResponse(metadata, Transforms.toBlobRequestConditions(requestConditions),
timeout, context);
return DataLakeImplUtils.returnOrConvertException(() ->
blockBlobClient.setMetadataWithResponse(metadata, Transforms.toBlobRequestConditions(requestConditions),
timeout, context), logger);
}

/**
Expand Down Expand Up @@ -232,8 +234,9 @@ public void setHttpHeaders(PathHttpHeaders headers) {
*/
public Response<Void> setHttpHeadersWithResponse(PathHttpHeaders headers,
DataLakeRequestConditions requestConditions, Duration timeout, Context context) {
return blockBlobClient.setHttpHeadersWithResponse(Transforms.toBlobHttpHeaders(headers),
Transforms.toBlobRequestConditions(requestConditions), timeout, context);
return DataLakeImplUtils.returnOrConvertException(() ->
blockBlobClient.setHttpHeadersWithResponse(Transforms.toBlobHttpHeaders(headers),
Transforms.toBlobRequestConditions(requestConditions), timeout, context), logger);
}

/**
Expand Down Expand Up @@ -400,9 +403,11 @@ public PathProperties getProperties() {
*/
public Response<PathProperties> getPropertiesWithResponse(DataLakeRequestConditions requestConditions,
Duration timeout, Context context) {
Response<BlobProperties> response = blockBlobClient.getPropertiesWithResponse(
Transforms.toBlobRequestConditions(requestConditions), timeout, context);
return new SimpleResponse<>(response, Transforms.toPathProperties(response.getValue()));
return DataLakeImplUtils.returnOrConvertException(() -> {
Response<BlobProperties> response = blockBlobClient.getPropertiesWithResponse(
Transforms.toBlobRequestConditions(requestConditions), timeout, context);
return new SimpleResponse<>(response, Transforms.toPathProperties(response.getValue()));
}, logger);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.azure.storage.common.sas.AccountSasSignatureValues;
import com.azure.storage.file.datalake.implementation.DataLakeStorageClientBuilder;
import com.azure.storage.file.datalake.implementation.DataLakeStorageClientImpl;
import com.azure.storage.file.datalake.implementation.util.DataLakeImplUtils;
import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
import com.azure.storage.file.datalake.models.FileSystemItem;
import com.azure.storage.file.datalake.models.ListFileSystemsOptions;
Expand Down Expand Up @@ -256,6 +257,7 @@ public PagedFlux<FileSystemItem> listFileSystems() {
public PagedFlux<FileSystemItem> listFileSystems(ListFileSystemsOptions options) {
try {
return blobServiceAsyncClient.listBlobContainers(Transforms.toListBlobContainersOptions(options))
// .onErrorMap(ex -> DataLakeImplUtils.transformBlobStorageException((BlobStorageException) ex))
.mapPage(Transforms::toFileSystemItem);
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
Expand All @@ -278,8 +280,7 @@ public PagedFlux<FileSystemItem> listFileSystems(ListFileSystemsOptions options)
*/
public Mono<UserDelegationKey> getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) {
try {
return blobServiceAsyncClient.getUserDelegationKey(start, expiry)
.map(Transforms::toDataLakeUserDelegationKey);
return this.getUserDelegationKeyWithResponse(start, expiry).flatMap(FluxUtil::toMono);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
Expand All @@ -303,7 +304,9 @@ public Mono<UserDelegationKey> getUserDelegationKey(OffsetDateTime start, Offset
public Mono<Response<UserDelegationKey>> getUserDelegationKeyWithResponse(OffsetDateTime start,
OffsetDateTime expiry) {
try {
return blobServiceAsyncClient.getUserDelegationKeyWithResponse(start, expiry).map(response ->
return blobServiceAsyncClient.getUserDelegationKeyWithResponse(start, expiry)
.onErrorMap(DataLakeImplUtils::transformBlobStorageException)
.map(response ->
new SimpleResponse<>(response, Transforms.toDataLakeUserDelegationKey(response.getValue())));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Loading