Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bc7f532
Clients and code samples for LeaseClients
alzimmermsft Sep 13, 2019
99948a4
Updated tests
alzimmermsft Sep 13, 2019
4b13ea4
Updating unit tests
alzimmermsft Sep 13, 2019
b36de0d
Using builder pattern for LeaseClients
alzimmermsft Sep 16, 2019
eeec369
Merge branch 'master' into AzStorage_LeaseClient
alzimmermsft Sep 16, 2019
0ba893a
Fix unit tests
alzimmermsft Sep 16, 2019
52f0a11
Cleaning up documentation
alzimmermsft Sep 16, 2019
52f9134
Fix linting issues and more unit tests
alzimmermsft Sep 16, 2019
1b18093
Merge branch 'master' into AzStorage_LeaseClient
alzimmermsft Sep 16, 2019
dcd005c
Some moving of clients
alzimmermsft Sep 16, 2019
65ea68c
Moved test files into correct folder
alzimmermsft Sep 16, 2019
28d6e77
Merge branch 'AzStorage_LeaseClient' into AzStorage_MoveSubBlobs
alzimmermsft Sep 16, 2019
a91f4ae
Moved sub-blob clients to specialized namespace, added BlobBaseClients
alzimmermsft Sep 17, 2019
d77b4cd
Refactoring unit tests
alzimmermsft Sep 17, 2019
63f0e1b
More cleaning up
alzimmermsft Sep 17, 2019
a619012
More cleaning up
alzimmermsft Sep 18, 2019
2f595bb
Merged in master
alzimmermsft Sep 19, 2019
51da041
Cleaning up linting issues
alzimmermsft Sep 20, 2019
307fd0d
Addressing PR feedback
alzimmermsft Sep 20, 2019
10d8ca6
Merged in master
alzimmermsft Sep 20, 2019
a49a98a
Merged in master
alzimmermsft Sep 23, 2019
d300657
Merged in master
alzimmermsft Sep 23, 2019
cc60e01
Merge branch 'master' into AzStorage_MoveSubBlobs
alzimmermsft Sep 24, 2019
8919c8c
Cleaning up Spotbug and linting issues
alzimmermsft Sep 24, 2019
43d31e6
Updated SpecializedBlobClientBuilder to be a full-fledged builder
alzimmermsft Sep 24, 2019
0b4b624
Merged in master
alzimmermsft Sep 25, 2019
d67ad67
Merged in master
alzimmermsft Sep 26, 2019
c4ba6ae
Updating CPK variable name and moving specialized test classes to spe…
alzimmermsft Sep 26, 2019
8cfcece
Cleaning up tests and linting
alzimmermsft Sep 26, 2019
b0538ce
Fix test order and added exception comment
alzimmermsft Sep 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,8 @@
<!-- -->
<suppress checks="LineLength" files="com.azure.storage.common.SR.java"/>
<suppress checks="LineLength" files=".*[/\\]storage[/\\].*(implementation|models)[/\\].*"/>

<!-- Suppress CRUD operation names as they won't feel fluent -->
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files="com.azure.storage.blob.specialized.LeaseClient.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files="com.azure.storage.blob.specialized.LeaseAsyncClient.java"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.azure.messaging.eventhubs.models.Checkpoint;
import com.azure.messaging.eventhubs.models.PartitionOwnership;
import com.azure.storage.blob.BlobAsyncClient;
import com.azure.storage.blob.BlockBlobAsyncClient;
import com.azure.storage.blob.specialized.BlockBlobAsyncClient;
import com.azure.storage.blob.ContainerAsyncClient;
import com.azure.storage.blob.models.BlobAccessConditions;
import com.azure.storage.blob.models.BlobItem;
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
import com.azure.core.implementation.annotation.ServiceClientBuilder;
import com.azure.core.util.logging.ClientLogger;
import com.azure.storage.blob.implementation.AzureBlobStorageBuilder;
import com.azure.storage.blob.implementation.AzureBlobStorageImpl;
import com.azure.storage.blob.models.LeaseAccessConditions;
import com.azure.storage.blob.models.PageRange;
import com.azure.storage.common.credentials.SASTokenCredential;
import reactor.core.publisher.Flux;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Objects;

/**
* This class provides a fluent builder API to help aid the configuration and instantiation Storage Blob clients.
* This class provides a fluent builder API to help aid the configuration and instantiation of
* {@link BlobClient BlobClients} and {@link BlobAsyncClient BlobAsyncClients} when
* {@link #buildBlobClient() buildBlobClient} and {@link #buildBlobAsyncClient() buildBlobAsyncClient} as called
* respectively.
*
* <p>
* The following information must be provided on this builder:
Expand All @@ -32,23 +29,8 @@
* <li>the credential through {@code .credential()} or {@code .connectionString()} if the container is not publicly
* accessible.
* </ul>
*
* <p>
* Once all the configurations are set on this builder use the following mapping to construct the given client:
* <ul>
* <li>{@link BlobClientBuilder#buildBlobClient()} - {@link BlobClient}</li>
* <li>{@link BlobClientBuilder#buildBlobAsyncClient()} - {@link BlobAsyncClient}</li>
* <li>{@link BlobClientBuilder#buildAppendBlobClient()} - {@link AppendBlobClient}</li>
* <li>{@link BlobClientBuilder#buildAppendBlobAsyncClient()} - {@link AppendBlobAsyncClient}</li>
* <li>{@link BlobClientBuilder#buildBlockBlobClient()} - {@link BlockBlobClient}</li>
* <li>{@link BlobClientBuilder#buildBlockBlobAsyncClient()} - {@link BlockBlobAsyncClient}</li>
* <li>{@link BlobClientBuilder#buildPageBlobClient()} - {@link PageBlobClient}</li>
* <li>{@link BlobClientBuilder#buildPageBlobAsyncClient()} - {@link PageBlobAsyncClient}</li>
* </ul>
*/
@ServiceClientBuilder(serviceClients = {BlobClient.class, BlobAsyncClient.class, AppendBlobClient.class,
AppendBlobAsyncClient.class, BlockBlobClient.class, BlockBlobAsyncClient.class, PageBlobClient.class,
PageBlobAsyncClient.class})
@ServiceClientBuilder(serviceClients = {BlobClient.class, BlobAsyncClient.class })
public final class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {

private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
Expand All @@ -58,26 +40,12 @@ public final class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBui
private String snapshot;

/**
* Creates a builder instance that is able to configure and construct Storage Blob clients.
* Creates a builder instance that is able to configure and construct {@link BlobClient BlobClients} and
* {@link BlobAsyncClient BlobAsyncClients}.
*/
public BlobClientBuilder() {
}

private AzureBlobStorageImpl constructImpl() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);

HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}

return new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoint, containerName, blobName))
.pipeline(pipeline)
.build();
}

/**
* Creates a {@link BlobClient} based on options set in the Builder. BlobClients are used to perform generic blob
* methods such as {@link BlobClient#download(OutputStream) download} and {@link BlobClient#getProperties() get
Expand Down Expand Up @@ -107,84 +75,18 @@ public BlobClient buildBlobClient() {
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public BlobAsyncClient buildBlobAsyncClient() {
return new BlobAsyncClient(constructImpl(), snapshot, cpk);
}

/**
* Creates a {@link AppendBlobClient} based on options set in the Builder. AppendBlobClients are used to perform
* append blob specific operations such as {@link AppendBlobClient#appendBlock(InputStream, long) append block},
* only use this when the blob is known to be an append blob.
*
* @return a {@link AppendBlobClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public AppendBlobClient buildAppendBlobClient() {
return new AppendBlobClient(buildAppendBlobAsyncClient());
}

/**
* Creates a {@link AppendBlobAsyncClient} based on options set in the Builder. AppendBlobAsyncClients are used to
* perform append blob specific operations such as {@link AppendBlobAsyncClient#appendBlock(Flux, long) append
* blob}, only use this when the blob is known to be an append blob.
*
* @return a {@link AppendBlobAsyncClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public AppendBlobAsyncClient buildAppendBlobAsyncClient() {
return new AppendBlobAsyncClient(constructImpl(), snapshot, cpk);
}

/**
* Creates a {@link BlockBlobClient} based on options set in the Builder. BlockBlobClients are used to perform
* generic upload operations such as {@link BlockBlobClient#uploadFromFile(String) upload from file} and block blob
* specific operations such as {@link BlockBlobClient#stageBlock(String, InputStream, long) stage block} and {@link
* BlockBlobClient#commitBlockList(List)}, only use this when the blob is known to be a block blob.
*
* @return a {@link BlockBlobClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public BlockBlobClient buildBlockBlobClient() {
return new BlockBlobClient(buildBlockBlobAsyncClient());
}

/**
* Creates a {@link BlockBlobAsyncClient} based on options set in the Builder. BlockBlobAsyncClients are used to
* perform generic upload operations such as {@link BlockBlobAsyncClient#uploadFromFile(String) upload from file}
* and block blob specific operations such as {@link BlockBlobAsyncClient#stageBlockWithResponse(String, Flux, long,
* LeaseAccessConditions) stage block} and {@link BlockBlobAsyncClient#commitBlockList(List) commit block list},
* only use this when the blob is known to be a block blob.
*
* @return a {@link BlockBlobAsyncClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public BlockBlobAsyncClient buildBlockBlobAsyncClient() {
return new BlockBlobAsyncClient(constructImpl(), snapshot, cpk);
}
Objects.requireNonNull(containerName);
Comment thread
alzimmermsft marked this conversation as resolved.
Outdated
Objects.requireNonNull(blobName);

/**
* Creates a {@link PageBlobClient} based on options set in the Builder. PageBlobClients are used to perform page
* blob specific operations such as {@link PageBlobClient#uploadPages(PageRange, InputStream) upload pages} and
* {@link PageBlobClient#clearPages(PageRange) clear pages}, only use this when the blob is known to be a page
* blob.
*
* @return a {@link PageBlobClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public PageBlobClient buildPageBlobClient() {
return new PageBlobClient(buildPageBlobAsyncClient());
}
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}

/**
* Creates a {@link PageBlobAsyncClient} based on options set in the Builder. PageBlobAsyncClients are used to
* perform page blob specific operations such as {@link PageBlobAsyncClient#uploadPages(PageRange, Flux) upload
* pages} and {@link PageBlobAsyncClient#clearPages(PageRange) clear pages}, only use this when the blob is known to
* be a page blob.
*
* @return a {@link PageBlobAsyncClient} created from the configurations in this builder.
* @throws NullPointerException If {@code endpoint}, {@code containerName}, or {@code blobName} is {@code null}.
*/
public PageBlobAsyncClient buildPageBlobAsyncClient() {
return new PageBlobAsyncClient(constructImpl(), snapshot, cpk);
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoint, containerName, blobName))
.pipeline(pipeline)
.build(), snapshot, cpk);
Comment thread
alzimmermsft marked this conversation as resolved.
Outdated
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class BlobProperties {
private final Metadata metadata;
private final Integer committedBlockCount;

BlobProperties(BlobGetPropertiesHeaders generatedHeaders) {
public BlobProperties(BlobGetPropertiesHeaders generatedHeaders) {
this.creationTime = generatedHeaders.getCreationTime();
this.lastModified = generatedHeaders.getLastModified();
this.eTag = generatedHeaders.getETag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

/**
* This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a blob. Setting
* a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all
* the values are set, this should be serialized with toString and set as the permissions field on a {@link
* BlobServiceSASSignatureValues} object. It is possible to construct the permissions string without this class, but the
* order of the permissions is particular and this class guarantees correctness.
* a value to true means that any SAS which uses these permissions will grant permissions for that operation. It is
* possible to construct the permissions string without this class, but the order of the permissions is particular and
* this class guarantees correctness.
*/
public final class BlobSASPermission {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.storage.blob;

import com.azure.core.implementation.http.UrlBuilder;
import com.azure.storage.blob.specialized.BlobServiceSASQueryParameters;
import com.azure.storage.common.Constants;
import com.azure.storage.common.Utility;

Expand All @@ -19,7 +20,7 @@
*
* <p>NOTE: Changing any SAS-related field requires computing a new SAS signature.</p>
*/
final class BlobURLParts {
public final class BlobURLParts {

private String scheme;

Expand All @@ -40,7 +41,7 @@ final class BlobURLParts {
* This may be useful for constructing a URL to a blob storage resource from scratch when the constituent parts are
* already known.
*/
BlobURLParts() {
public BlobURLParts() {
unparsedParameters = new HashMap<>();
}

Expand Down
Loading