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

Add Storage Module to POM #4338

Merged
merged 17 commits into from
Jul 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
<!-- Suppress non-null warning in the case that we change the code and it is possible for
KeyVaultCredentials.getAuthenticationCredentials to return null. -->
<Match>
<Class name="com.microsoft.azure.keyvault.authentication.KeyVaultCredentials"/>
<Or>
<Class name="com.microsoft.azure.keyvault.authentication.KeyVaultCredentials"/>
<Class name="com.azure.storage.blob.implementation.AzureBlobStorageBuilder"/>
</Or>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>

Expand Down Expand Up @@ -104,7 +107,10 @@
<!-- Known issue in autorest where it will generate a variable with a value of null.
https://github.com/Azure/autorest.java/issues/324 -->
<Match>
<Class name="~com\.microsoft\.azure\.(.+)Impl"/>
<Or>
<Class name="~com\.microsoft\.azure\.(.+)Impl"/>
<Class name="~com\.azure\.(.+)Impl"/>
</Or>
<Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
</Match>

Expand Down Expand Up @@ -238,7 +244,10 @@
<!-- Known issue in autorest where it will generate a variable with a value of null then use it in a not null check.
https://github.com/Azure/autorest.java/issues/328 -->
<Match>
<Class name="~com\.microsoft\.azure\.batch\.protocol\.implementation\.[\w]+Impl"/>
<Or>
<Class name="~com\.microsoft\.azure\.batch\.protocol\.implementation\.[\w]+Impl"/>
<Class name="com.azure.storage.blob.implementation.AzureBlobStorageBuilder"/>
</Or>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"/>
</Match>

Expand Down Expand Up @@ -357,7 +366,10 @@

<!-- Exclude the confusing name bugs as it is designed to name the same as autorest. -->
<Match>
<Package name="com.microsoft.azure.storage.blob"/>
<Or>
<Package name="com.microsoft.azure.storage.blob"/>
<Class name="com.azure.storage.blob.HTTPGetterInfo"/>
</Or>
<Bug pattern="NM_CONFUSING"/>
</Match>
alzimmermsft marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -422,6 +434,15 @@
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>

<!-- Incorrect flagging, if the response is null a StorageException would have been thrown -->
<Match>
<Or>
<Class name="com.azure.storage.blob.BlobInputStream"/>
<Class name="com.azure.storage.blob.BlobOutputStream"/>
</Or>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>

<!-- Super doesn't need to be cloned since it is Object -->
<Match>
<Class name="com.azure.core.util.configuration.Configuration"/>
Expand Down
5 changes: 5 additions & 0 deletions pom.client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@
<title>Azure Key Vault</title>
<packages>com.azure.security.keyvault*</packages>
</group>
<group>
<title>Azure Storage - Blobs</title>
<packages>com.azure.storage.blob*</packages>
</group>
alzimmermsft marked this conversation as resolved.
Show resolved Hide resolved
</groups>
<links>
<link>https://docs.oracle.com/javase/8/docs/api/</link>
Expand Down Expand Up @@ -740,5 +744,6 @@
<!-- As recommended by Eng Sys team, removing tracing as it is built and released separately -->
<!-- <module>./sdk/tracing</module>-->
<module>./sdk/identity/azure-identity</module>
<module>./storage/client/blob</module>
</modules>
</project>
75 changes: 11 additions & 64 deletions storage/client/blob/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- Added this dependency to include necessary annotations used by reactor core.
Without this dependency, javadoc throws a warning as it cannot find enum When.MAYBE
which is used in @Nullable annotation in reactor core classes -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.0.0-preview.2</version>
<scope>test</scope>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.0.0-preview.1</version>
<artifactId>azure-core-test</artifactId>
<version>1.0.0-preview.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -141,64 +145,7 @@
</dependency>
</dependencies>
</plugin>
<!-- Now that all checkstyle issues have been resolved, override the
default behavior to make checkstyle fail on error and violation. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
<failOnWarnings>false</failOnWarnings>
</configuration>
</plugin>

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<!-- Now that all checkstyle issues have been resolved, override the
default behavior to make checkstyle fail on error and violation. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
<failOnWarnings>false</failOnWarnings>
</configuration>
</plugin>

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</reporting>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class AccountSASPermission {
/**
* Initializes an {@code AccountSASPermission} object with all fields set to false.
*/
public AccountSASPermission() {
private AccountSASPermission() {
}

/**
Expand All @@ -44,6 +44,7 @@ public AccountSASPermission() {
* A {@code String} which represents the {@code SharedAccessAccountPermissions}.
*
* @return An {@code AccountSASPermission} object generated from the given {@code String}.
* @throws IllegalArgumentException If {@code permString} contains a character other than r, w, d, l, a, c, u, or p.
*/
public static AccountSASPermission parse(String permString) {
AccountSASPermission permissions = new AccountSASPermission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class AccountSASResourceType {
/**
* Initializes an {@code AccountSASResourceType} object with all fields set to false.
*/
public AccountSASResourceType() {
private AccountSASResourceType() {
}

/**
Expand All @@ -34,6 +34,7 @@ public AccountSASResourceType() {
* A {@code String} which represents the {@code AccountSASResourceTypes}.
*
* @return A {@code AccountSASResourceType} generated from the given {@code String}.
* @throws IllegalArgumentException If {@code resourceTypesString} contains a character other than s, c, or o.
*/
public static AccountSASResourceType parse(String resourceTypesString) {
AccountSASResourceType resourceType = new AccountSASResourceType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class AccountSASService {
/**
* Initializes an {@code AccountSASService} object with all fields set to false.
*/
public AccountSASService() {
private AccountSASService() {
}

/**
Expand All @@ -36,6 +36,7 @@ public AccountSASService() {
* A {@code String} which represents the {@code SharedAccessAccountServices}.
*
* @return A {@code AccountSASService} generated from the given {@code String}.
* @throws IllegalArgumentException If {@code servicesString} contains a character other than b, f, q, or t.
*/
public static AccountSASService parse(String servicesString) {
AccountSASService services = new AccountSASService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class AccountSASSignatureValues {
* Initializes an {@code AccountSASSignatureValues} object with the version number set to the default and all
* other values empty.
*/
public AccountSASSignatureValues() {
AccountSASSignatureValues() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have reason why you have private constructor for AccountSASSerivce, but protected here?

}

/**
Expand Down Expand Up @@ -187,6 +187,7 @@ public AccountSASSignatureValues resourceTypes(String resourceTypes) {
* Credentials for the storage account and corresponding primary or secondary key.
*
* @return {@link SASQueryParameters}
* @throws RuntimeException If the HMAC-SHA256 signature for {@code sharedKeyCredentials} fails to generate.
*/
public SASQueryParameters generateSASQueryParameters(SharedKeyCredential sharedKeyCredentials) {
Utility.assertNotNull("SharedKeyCredential", sharedKeyCredentials);
Expand All @@ -203,7 +204,7 @@ public SASQueryParameters generateSASQueryParameters(SharedKeyCredential sharedK
try {
signature = sharedKeyCredentials.computeHmac256(stringToSign);
} catch (InvalidKeyException e) {
throw new Error(e); // The key should have been validated by now. If it is no longer valid here, we fail.
throw new RuntimeException(e); // The key should have been validated by now. If it is no longer valid here, we fail.
}

return new SASQueryParameters(this.version, this.services, resourceTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ public Mono<Response<AppendBlobItem>> create() {
* @return
* A reactive response containing the information of the created appended blob.
*/
public Mono<Response<AppendBlobItem>> create(BlobHTTPHeaders headers, Metadata metadata,
BlobAccessConditions accessConditions) {
return appendBlobAsyncRawClient
.create(headers, metadata, accessConditions)
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
public Mono<Response<AppendBlobItem>> create(BlobHTTPHeaders headers, Metadata metadata, BlobAccessConditions accessConditions) {
return appendBlobAsyncRawClient
.create(headers, metadata, accessConditions)
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.deserializedHeaders())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.azure.storage.blob.models.BlobRange;
import com.azure.storage.blob.models.Metadata;
import com.azure.storage.blob.models.SourceModifiedAccessConditions;
import io.netty.buffer.ByteBufAllocator;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

Expand All @@ -40,7 +40,7 @@
* <p>
* The following information must be provided on this builder:
*
* <p><ul>
* <ul>
* <li>the endpoint through {@code .endpoint()}, including the container name and blob name, in the format of {@code https://{accountName}.blob.core.windows.net/{containerName}/{blobName}}.
* <li>the credential through {@code .credential()} or {@code .connectionString()} if the container is not publicly accessible.
* </ul>
Expand Down Expand Up @@ -69,6 +69,10 @@ public final class AppendBlobClientBuilder {
private RequestRetryOptions retryOptions;
private Configuration configuration;

/**
* Creates a builder instance that is able to configure and construct {@link AppendBlobClient AppendBlobClients}
* and {@link AppendBlobAsyncClient AppendBlobAsyncClients}.
*/
public AppendBlobClientBuilder() {
retryOptions = new RequestRetryOptions();
logLevel = HttpLogDetailLevel.NONE;
Expand Down Expand Up @@ -98,7 +102,7 @@ private AzureBlobStorageBuilder buildImpl() {
policies.add(new SASTokenCredentialPolicy(sasTokenCredential));
} else {
policies.add(new AnonymousCredentialPolicy());
}
}

policies.add(new RequestRetryPolicy(retryOptions));

Expand Down Expand Up @@ -133,6 +137,7 @@ public AppendBlobAsyncClient buildAsyncClient() {
* Sets the service endpoint, additionally parses it for information (SAS token, container name, blob name)
* @param endpoint URL of the service
* @return the updated AppendBlobClientBuilder object
* @throws IllegalArgumentException If {@code endpoint} is a malformed URL or is using an unknown host.
*/
public AppendBlobClientBuilder endpoint(String endpoint) {
Objects.requireNonNull(endpoint);
Expand All @@ -153,7 +158,7 @@ public AppendBlobClientBuilder endpoint(String endpoint) {
if (parts.snapshot() != null) {
this.snapshot = parts.snapshot();
}
} catch (MalformedURLException | UnknownHostException ex) {
} catch (MalformedURLException ex) {
throw new IllegalArgumentException("The Azure Storage Blob endpoint url is malformed.");
}

Expand Down Expand Up @@ -246,14 +251,15 @@ public AppendBlobClientBuilder anonymousCredential() {
* Sets the connection string for the service, parses it for authentication information (account name, account key)
* @param connectionString connection string from access keys section
* @return the updated AppendBlobClientBuilder object
* @throws IllegalArgumentException If {@code connectionString} doesn't contain AccountName or AccountKey.
*/
public AppendBlobClientBuilder connectionString(String connectionString) {
Objects.requireNonNull(connectionString);

Map<String, String> connectionKVPs = new HashMap<>();
for (String s : connectionString.split(";")) {
String[] kvp = s.split("=", 2);
connectionKVPs.put(kvp[0].toLowerCase(), kvp[1]);
connectionKVPs.put(kvp[0].toLowerCase(Locale.ROOT), kvp[1]);
}

String accountName = connectionKVPs.get(ACCOUNT_NAME);
Expand Down
Loading