Skip to content

Commit

Permalink
Merge pull request Azure#54 from wastore/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jofriedm-msft authored May 4, 2017
2 parents d8ba06b + c37d571 commit 81d62db
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 46 deletions.
2 changes: 0 additions & 2 deletions BreakingChanges.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Changes in 5.1.0

FILE
* Exists() calls on Shares and Directories now populates metadata. This was already being done for Files.
* Changed listShares() ShareListingDetails parameter to be an enum set like what is done for listing blobs.
* In CloudFileShareProperties, setShareQuota() no longer asserts in bounds. This check has been moved to create() and uploadProperties() in CloudFileShare.

BLOB/FILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testListSharesTest() throws StorageException, URISyntaxException {
do {

ResultSegment<CloudFileShare> segment = fileClient.listSharesSegmented(prefix,
EnumSet.allOf(ShareListingDetails.class), 15, token, null, null);
ShareListingDetails.ALL, 15, token, null, null);

for (final CloudFileShare share : segment.getResults()) {
share.downloadAttributes();
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testListSharesMaxResultsValidationTest() throws StorageException, UR
for (int i = 0; i >= -2; i--) {
try{
fileClient.listSharesSegmented(
prefix, EnumSet.allOf(ShareListingDetails.class), i, null, null, null);
prefix, ShareListingDetails.ALL, i, null, null, null);
fail();
}
catch (IllegalArgumentException e) {
Expand Down Expand Up @@ -133,7 +133,7 @@ public void testListSharesWithSnapshot() throws StorageException, URISyntaxExcep
share.uploadMetadata();

CloudFileClient client = FileTestHelper.createCloudFileClient();
Iterable<CloudFileShare> listResult = client.listShares(share.name, EnumSet.allOf(ShareListingDetails.class), null, null);
Iterable<CloudFileShare> listResult = client.listShares(share.name, ShareListingDetails.ALL, null, null);

int count = 0;
boolean originalFound = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void testCloudFileShareUploadMetadata() throws StorageException, URISynta
Assert.assertEquals("value2", this.share.getMetadata().get("key2"));

Iterable<CloudFileShare> shares = this.share.getServiceClient().listShares(this.share.getName(),
EnumSet.of(ShareListingDetails.METADATA), null, null);
ShareListingDetails.METADATA, null, null);

for (CloudFileShare share3 : shares) {
Assert.assertEquals(2, share3.getMetadata().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected CloudFileShare getShareReference(final String shareName, String snapsh
*/
@DoesServiceRequest
public Iterable<CloudFileShare> listShares() {
return this.listSharesWithPrefix(null, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */);
return this.listSharesWithPrefix(null, ShareListingDetails.NONE, null /* options */, null /* opContext */);
}

/**
Expand All @@ -149,7 +149,7 @@ public Iterable<CloudFileShare> listShares() {
*/
@DoesServiceRequest
public Iterable<CloudFileShare> listShares(final String prefix) {
return this.listSharesWithPrefix(prefix, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */);
return this.listSharesWithPrefix(prefix, ShareListingDetails.NONE, null /* options */, null /* opContext */);
}

/**
Expand All @@ -159,8 +159,7 @@ public Iterable<CloudFileShare> listShares(final String prefix) {
* @param prefix
* A <code>String</code> that represents the share name prefix.
* @param detailsIncluded
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
* whether share snapshots and/or metadata will be returned.
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
Expand All @@ -174,7 +173,7 @@ public Iterable<CloudFileShare> listShares(final String prefix) {
* shares for this client.
*/
@DoesServiceRequest
public Iterable<CloudFileShare> listShares(final String prefix, final EnumSet<ShareListingDetails> detailsIncluded,
public Iterable<CloudFileShare> listShares(final String prefix, final ShareListingDetails detailsIncluded,
final FileRequestOptions options, final OperationContext opContext) {
return this.listSharesWithPrefix(prefix, detailsIncluded, options, opContext);
}
Expand All @@ -190,7 +189,7 @@ public Iterable<CloudFileShare> listShares(final String prefix, final EnumSet<Sh
*/
@DoesServiceRequest
public ResultSegment<CloudFileShare> listSharesSegmented() throws StorageException {
return this.listSharesSegmented(null, EnumSet.noneOf(ShareListingDetails.class), null, null /* continuationToken */,
return this.listSharesSegmented(null, ShareListingDetails.NONE, null, null /* continuationToken */,
null /* options */, null /* opContext */);
}

Expand All @@ -210,7 +209,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented() throws StorageExcepti
*/
@DoesServiceRequest
public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix) throws StorageException {
return this.listSharesWithPrefixSegmented(prefix, EnumSet.noneOf(ShareListingDetails.class), null, null /* continuationToken */,
return this.listSharesWithPrefixSegmented(prefix, ShareListingDetails.NONE, null, null /* continuationToken */,
null /* options */, null /* opContext */);
}

Expand All @@ -221,8 +220,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix) th
* @param prefix
* A <code>String</code> that represents the prefix of the share name.
* @param detailsIncluded
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
* whether share snapshots and/or metadata will be returned.
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
* @param maxResults
* The maximum number of results to retrieve. If <code>null</code> or greater
* than 5000, the server will return up to 5,000 items. Must be at least 1.
Expand All @@ -246,7 +244,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix) th
*/
@DoesServiceRequest
public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix,
final EnumSet<ShareListingDetails> detailsIncluded, final Integer maxResults,
final ShareListingDetails detailsIncluded, final Integer maxResults,
final ResultContinuation continuationToken, final FileRequestOptions options,
final OperationContext opContext) throws StorageException {
return this.listSharesWithPrefixSegmented(prefix, detailsIncluded, maxResults, continuationToken, options,
Expand All @@ -260,8 +258,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix,
* @param prefix
* A <code>String</code> that represents the prefix of the share name.
* @param detailsIncluded
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails}
* values that indicate whether snapshots and/or metadata are returned.
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
Expand All @@ -275,7 +272,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix,
* shares whose names begin with the specified prefix.
*/
private Iterable<CloudFileShare> listSharesWithPrefix(final String prefix,
final EnumSet<ShareListingDetails> detailsIncluded, FileRequestOptions options, OperationContext opContext) {
final ShareListingDetails detailsIncluded, FileRequestOptions options, OperationContext opContext) {
if (opContext == null) {
opContext = new OperationContext();
}
Expand All @@ -297,8 +294,7 @@ private Iterable<CloudFileShare> listSharesWithPrefix(final String prefix,
* @param prefix
* A <code>String</code> that represents the prefix of the share name.
* @param detailsIncluded
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
* whether share snapshots and/or metadata will be returned.
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
* @param maxResults
* The maximum number of results to retrieve. If <code>null</code> or greater
* than 5000, the server will return up to 5,000 items. Must be at least 1.
Expand All @@ -321,7 +317,7 @@ private Iterable<CloudFileShare> listSharesWithPrefix(final String prefix,
* If a storage service error occurred.
*/
private ResultSegment<CloudFileShare> listSharesWithPrefixSegmented(final String prefix,
final EnumSet<ShareListingDetails> detailsIncluded, final Integer maxResults,
final ShareListingDetails detailsIncluded, final Integer maxResults,
final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
Expand All @@ -342,7 +338,7 @@ private ResultSegment<CloudFileShare> listSharesWithPrefixSegmented(final String
}

private StorageRequest<CloudFileClient, Void, ResultSegment<CloudFileShare>> listSharesWithPrefixSegmentedImpl(
final String prefix, final EnumSet<ShareListingDetails> detailsIncluded, final Integer maxResults,
final String prefix, final ShareListingDetails detailsIncluded, final Integer maxResults,
final FileRequestOptions options, final SegmentedStorageRequest segmentedRequest) {

Utility.assertContinuationType(segmentedRequest.getToken(), ResultContinuationType.SHARE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,12 @@ public void signRequest(HttpURLConnection connection, CloudFileClient client, Op
public Boolean preProcessResponse(CloudFileDirectory directory, CloudFileClient client,
OperationContext context) throws Exception {
if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) {
// Set properties
final FileDirectoryAttributes attributes =
FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris());
directory.setMetadata(attributes.getMetadata());
directory.setProperties(attributes.getProperties());
directory.updatePropertiesFromResponse(this.getConnection());
// // Set properties
// final FileDirectoryAttributes attributes =
// FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris());
// directory.setMetadata(attributes.getMetadata());
// directory.setProperties(attributes.getProperties());

return Boolean.valueOf(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,11 @@ public void signRequest(HttpURLConnection connection, CloudFileClient client, Op
public Boolean preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context)
throws Exception {
if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) {
final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(),
client.isUsePathStyleUris());
share.metadata = attributes.getMetadata();
share.properties = attributes.getProperties();
share.updatePropertiesFromResponse(this.getConnection());
// final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(),
// client.isUsePathStyleUris());
// share.metadata = attributes.getMetadata();
// share.properties = attributes.getProperties();

return Boolean.valueOf(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,7 @@ private static HttpURLConnection getProperties(final URI uri, final FileRequestO
* @param listingContext
* A set of parameters for the listing operation.
* @param detailsIncluded
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
* whether share snapshots and/or metadata will be returned.
* Additional details to return with the listing.
* @return a HttpURLConnection configured for the operation.
* @throws IOException
* @throws URISyntaxException
Expand All @@ -650,28 +649,32 @@ private static HttpURLConnection getProperties(final URI uri, final FileRequestO
*/
public static HttpURLConnection listShares(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final ListingContext listingContext,
final EnumSet<ShareListingDetails> detailsIncluded) throws URISyntaxException, IOException, StorageException {
final ShareListingDetails detailsIncluded) throws URISyntaxException, IOException, StorageException {
final UriQueryBuilder builder = BaseRequest.getListUriQueryBuilder(listingContext);

if (detailsIncluded != null && detailsIncluded.size() > 0) {
final StringBuilder sb = new StringBuilder();
boolean started = false;
// if (detailsIncluded != null && detailsIncluded.size() > 0) {
// final StringBuilder sb = new StringBuilder();
// boolean started = false;

// if (detailsIncluded.contains(ShareListingDetails.SNAPSHOTS)) {
// started = true;
// sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME);
// }

if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
if (started)
{
sb.append(",");
}
// if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
// if (started)
// {
// sb.append(",");
// }
//
// sb.append(Constants.QueryConstants.METADATA);
// }

sb.append(Constants.QueryConstants.METADATA);
}
// builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
// }

builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
if (detailsIncluded == ShareListingDetails.ALL || detailsIncluded == ShareListingDetails.METADATA) {
builder.add(Constants.QueryConstants.INCLUDE, Constants.QueryConstants.METADATA);
}

final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
*/
public enum ShareListingDetails {

/**
* Specifies including no additional details.
*/
NONE(0),

/**
* Specifies including all available details.
*/
ALL(1),

/**
* Specifies including share metadata.
*/
Expand Down

0 comments on commit 81d62db

Please sign in to comment.