Skip to content

Commit

Permalink
Merge back Storage UX study changes (Azure#3973)
Browse files Browse the repository at this point in the history
* Refactored for Track 2 according to design

* Conversion of client classes to conform to new architecture

* Addressed Compile Errors

Converted most classes to use com.azure.core as well as Reactor.
Excluded classes include
 * All "Clients" (handled elsewhere)
 * RequestRetryFactory (scheduled work)
 * Logging Factory (nontrivial and not necessary for upcoming milestone)

* Refactored ServiceClient to BlobServiceClient

* Convert methods in async raw to return Mono

* Initial builder work

* Blob Client x4 Restructured

Client design pattern for upcoming tests applied to BlobClient.
 * ___Client wraps ___AsyncClient
 * ___AsyncClient wraps ___AsyncRawClient
 * ___RawClient wraps AsyncRawClient
Raw blob clients are package-protected. Non-Raw blob clients are public.
All blob client constructors are package-protected, awaiting a builder.
Work for the other 5 client types is upcoming.

* Add builders for generated clients

* Add builders

* Add builders for clients

* NOT COMPLETE - Added correct types to method signatures in 4 sub types of client classes

* Completed correct method return types for all 4 sub types of clients

* Finished builder pattern implementation.

* Fixed page blob client builders

* Compiles!

* Halfway commit

Addressed some issues where sync clients used async method parameters.

* BlobClient javadocs

* Append, block, page blob javadocs

* Container client javadocs

* BlobServiceClientBuilder and related javadocs

* Add blob api test

* Cleaned up a few things

* Support creating child clients

* Add block blob api test

* Add Alan's SharedKeyCredential

* Fixed most upload/download logic.

* more block blob API test

* Minor fix to async block blob upload

* Set several classes to package-private

Postponing judgement of several classes carried over from v11 library.

* Temporarlily included a test sample file.

Includes REST operations
 * create container
 * list blobs
 * put blob (block blob)
 * get blob

* Add more docs for builders

* Temporarlily included a test sample file.

Includes REST operations
 * create container
 * list blobs
 * put blob (block blob)
 * get blob

* Minor fix

* Blob unit tests compile

* Minor fix

* Fix some compile issues in block blob tests

* Fixed signatures for listing containers.

Updated temporary sample file to show usage.

* Removed key

* Block blob tests pass

* Convert champion and hi pri tests.

* Most tests passing, commented out tests that cannot pass

* Added naive approaches to upload/download from file methods

* Fix connection string

* clean up imports

* Delete duplicate shared key credential

* More clean up

* Return types never return protocol-layer classes

They may return auto-gen models, but won't return ___Response or
___Headers.

* Add line breaks to class level docs

* Missing import

* Make builder constructor public

* Regenerate blob with fixed AutoRest

* Rename blob service client builder method

* Add more javadocs on builder

* Add more javadocs

* Add more info for list

* Minor changes

* Make BlobRange immutable and getContainerClient

* Clean up storage client docs

* More docs and changes from UX studies

* Fix typo
  • Loading branch information
jianghaolu authored and sima-zhu committed Jun 20, 2019
1 parent 6788aad commit 33e89c3
Show file tree
Hide file tree
Showing 118 changed files with 25,619 additions and 123 deletions.
21 changes: 20 additions & 1 deletion storage/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -79,7 +99,6 @@
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.storage.blob;

import java.util.Locale;

/**
* This is a helper class to construct a string representing the permissions granted by an AccountSAS. 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 an
* {@link AccountSASSignatureValues} 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.
*/
final class AccountSASPermission {

private boolean read;

private boolean add;

private boolean create;

private boolean write;

private boolean delete;

private boolean list;

private boolean update;

private boolean processMessages;

/**
* Initializes an {@code AccountSASPermission} object with all fields set to false.
*/
public AccountSASPermission() {
}

/**
* Creates an {@code AccountSASPermission} from the specified permissions string. This method will throw an
* {@code IllegalArgumentException} if it encounters a character that does not correspond to a valid permission.
*
* @param permString
* A {@code String} which represents the {@code SharedAccessAccountPermissions}.
*
* @return An {@code AccountSASPermission} object generated from the given {@code String}.
*/
public static AccountSASPermission parse(String permString) {
AccountSASPermission permissions = new AccountSASPermission();

for (int i = 0; i < permString.length(); i++) {
char c = permString.charAt(i);
switch (c) {
case 'r':
permissions.read = true;
break;
case 'w':
permissions.write = true;
break;
case 'd':
permissions.delete = true;
break;
case 'l':
permissions.list = true;
break;
case 'a':
permissions.add = true;
break;
case 'c':
permissions.create = true;
break;
case 'u':
permissions.update = true;
break;
case 'p':
permissions.processMessages = true;
break;
default:
throw new IllegalArgumentException(
String.format(Locale.ROOT, SR.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE, "Permissions", permString, c));
}
}
return permissions;
}

/**
* Permission to read resources and list queues and tables granted.
*/
public boolean read() {
return read;
}

/**
* Permission to read resources and list queues and tables granted.
*/
public AccountSASPermission withRead(boolean read) {
this.read = read;
return this;
}

/**
* Permission to add messages, table entities, and append to blobs granted.
*/
public boolean add() {
return add;
}

/**
* Permission to add messages, table entities, and append to blobs granted.
*/
public AccountSASPermission withAdd(boolean add) {
this.add = add;
return this;
}

/**
* Permission to create blobs and files granted.
*/
public boolean create() {
return create;
}

/**
* Permission to create blobs and files granted.
*/
public AccountSASPermission withCreate(boolean create) {
this.create = create;
return this;
}

/**
* Permission to write resources granted.
*/
public boolean write() {
return write;
}

/**
* Permission to write resources granted.
*/
public AccountSASPermission withWrite(boolean write) {
this.write = write;
return this;
}

/**
* Permission to delete resources granted.
*/
public boolean delete() {
return delete;
}

/**
* Permission to delete resources granted.
*/
public AccountSASPermission withDelete(boolean delete) {
this.delete = delete;
return this;
}

/**
* Permission to list blob containers, blobs, shares, directories, and files granted.
*/
public boolean list() {
return list;
}

/**
* Permission to list blob containers, blobs, shares, directories, and files granted.
*/
public AccountSASPermission withList(boolean list) {
this.list = list;
return this;
}

/**
* Permissions to update messages and table entities granted.
*/
public boolean update() {
return update;
}

/**
* Permissions to update messages and table entities granted.
*/
public AccountSASPermission withUpdate(boolean update) {
this.update = update;
return this;
}

/**
* Permission to get and delete messages granted.
*/
public boolean processMessages() {
return processMessages;
}

/**
* Permission to get and delete messages granted.
*/
public AccountSASPermission withProcessMessages(boolean processMessages) {
this.processMessages = processMessages;
return this;
}

/**
* Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an
* order accepted by the service.
*
* @return A {@code String} which represents the {@code AccountSASPermissions}.
*/
@Override
public String toString() {
// The order of the characters should be as specified here to ensure correctness:
// https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas
final StringBuilder builder = new StringBuilder();

if (this.read) {
builder.append('r');
}

if (this.write) {
builder.append('w');
}

if (this.delete) {
builder.append('d');
}

if (this.list) {
builder.append('l');
}

if (this.add) {
builder.append('a');
}

if (this.create) {
builder.append('c');
}

if (this.update) {
builder.append('u');
}

if (this.processMessages) {
builder.append('p');
}

return builder.toString();
}
}
Loading

0 comments on commit 33e89c3

Please sign in to comment.