Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 81d62db

Browse files
author
jofriedm-msft
authored
Merge pull request #54 from wastore/dev
Dev
2 parents d8ba06b + c37d571 commit 81d62db

File tree

8 files changed

+55
-46
lines changed

8 files changed

+55
-46
lines changed

BreakingChanges.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Changes in 5.1.0
22

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

86
BLOB/FILE

microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileClientTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testListSharesTest() throws StorageException, URISyntaxException {
6767
do {
6868

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

7272
for (final CloudFileShare share : segment.getResults()) {
7373
share.downloadAttributes();
@@ -104,7 +104,7 @@ public void testListSharesMaxResultsValidationTest() throws StorageException, UR
104104
for (int i = 0; i >= -2; i--) {
105105
try{
106106
fileClient.listSharesSegmented(
107-
prefix, EnumSet.allOf(ShareListingDetails.class), i, null, null, null);
107+
prefix, ShareListingDetails.ALL, i, null, null, null);
108108
fail();
109109
}
110110
catch (IllegalArgumentException e) {
@@ -133,7 +133,7 @@ public void testListSharesWithSnapshot() throws StorageException, URISyntaxExcep
133133
share.uploadMetadata();
134134

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

138138
int count = 0;
139139
boolean originalFound = false;

microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileShareTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public void testCloudFileShareUploadMetadata() throws StorageException, URISynta
318318
Assert.assertEquals("value2", this.share.getMetadata().get("key2"));
319319

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

323323
for (CloudFileShare share3 : shares) {
324324
Assert.assertEquals(2, share3.getMetadata().size());

microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileClient.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected CloudFileShare getShareReference(final String shareName, String snapsh
134134
*/
135135
@DoesServiceRequest
136136
public Iterable<CloudFileShare> listShares() {
137-
return this.listSharesWithPrefix(null, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */);
137+
return this.listSharesWithPrefix(null, ShareListingDetails.NONE, null /* options */, null /* opContext */);
138138
}
139139

140140
/**
@@ -149,7 +149,7 @@ public Iterable<CloudFileShare> listShares() {
149149
*/
150150
@DoesServiceRequest
151151
public Iterable<CloudFileShare> listShares(final String prefix) {
152-
return this.listSharesWithPrefix(prefix, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */);
152+
return this.listSharesWithPrefix(prefix, ShareListingDetails.NONE, null /* options */, null /* opContext */);
153153
}
154154

155155
/**
@@ -159,8 +159,7 @@ public Iterable<CloudFileShare> listShares(final String prefix) {
159159
* @param prefix
160160
* A <code>String</code> that represents the share name prefix.
161161
* @param detailsIncluded
162-
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
163-
* whether share snapshots and/or metadata will be returned.
162+
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
164163
* @param options
165164
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
166165
* <code>null</code> will use the default request options from the associated service client (
@@ -174,7 +173,7 @@ public Iterable<CloudFileShare> listShares(final String prefix) {
174173
* shares for this client.
175174
*/
176175
@DoesServiceRequest
177-
public Iterable<CloudFileShare> listShares(final String prefix, final EnumSet<ShareListingDetails> detailsIncluded,
176+
public Iterable<CloudFileShare> listShares(final String prefix, final ShareListingDetails detailsIncluded,
178177
final FileRequestOptions options, final OperationContext opContext) {
179178
return this.listSharesWithPrefix(prefix, detailsIncluded, options, opContext);
180179
}
@@ -190,7 +189,7 @@ public Iterable<CloudFileShare> listShares(final String prefix, final EnumSet<Sh
190189
*/
191190
@DoesServiceRequest
192191
public ResultSegment<CloudFileShare> listSharesSegmented() throws StorageException {
193-
return this.listSharesSegmented(null, EnumSet.noneOf(ShareListingDetails.class), null, null /* continuationToken */,
192+
return this.listSharesSegmented(null, ShareListingDetails.NONE, null, null /* continuationToken */,
194193
null /* options */, null /* opContext */);
195194
}
196195

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

@@ -221,8 +220,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix) th
221220
* @param prefix
222221
* A <code>String</code> that represents the prefix of the share name.
223222
* @param detailsIncluded
224-
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
225-
* whether share snapshots and/or metadata will be returned.
223+
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
226224
* @param maxResults
227225
* The maximum number of results to retrieve. If <code>null</code> or greater
228226
* than 5000, the server will return up to 5,000 items. Must be at least 1.
@@ -246,7 +244,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix) th
246244
*/
247245
@DoesServiceRequest
248246
public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix,
249-
final EnumSet<ShareListingDetails> detailsIncluded, final Integer maxResults,
247+
final ShareListingDetails detailsIncluded, final Integer maxResults,
250248
final ResultContinuation continuationToken, final FileRequestOptions options,
251249
final OperationContext opContext) throws StorageException {
252250
return this.listSharesWithPrefixSegmented(prefix, detailsIncluded, maxResults, continuationToken, options,
@@ -260,8 +258,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix,
260258
* @param prefix
261259
* A <code>String</code> that represents the prefix of the share name.
262260
* @param detailsIncluded
263-
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails}
264-
* values that indicate whether snapshots and/or metadata are returned.
261+
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
265262
* @param options
266263
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
267264
* <code>null</code> will use the default request options from the associated service client (
@@ -275,7 +272,7 @@ public ResultSegment<CloudFileShare> listSharesSegmented(final String prefix,
275272
* shares whose names begin with the specified prefix.
276273
*/
277274
private Iterable<CloudFileShare> listSharesWithPrefix(final String prefix,
278-
final EnumSet<ShareListingDetails> detailsIncluded, FileRequestOptions options, OperationContext opContext) {
275+
final ShareListingDetails detailsIncluded, FileRequestOptions options, OperationContext opContext) {
279276
if (opContext == null) {
280277
opContext = new OperationContext();
281278
}
@@ -297,8 +294,7 @@ private Iterable<CloudFileShare> listSharesWithPrefix(final String prefix,
297294
* @param prefix
298295
* A <code>String</code> that represents the prefix of the share name.
299296
* @param detailsIncluded
300-
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
301-
* whether share snapshots and/or metadata will be returned.
297+
* A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
302298
* @param maxResults
303299
* The maximum number of results to retrieve. If <code>null</code> or greater
304300
* than 5000, the server will return up to 5,000 items. Must be at least 1.
@@ -321,7 +317,7 @@ private Iterable<CloudFileShare> listSharesWithPrefix(final String prefix,
321317
* If a storage service error occurred.
322318
*/
323319
private ResultSegment<CloudFileShare> listSharesWithPrefixSegmented(final String prefix,
324-
final EnumSet<ShareListingDetails> detailsIncluded, final Integer maxResults,
320+
final ShareListingDetails detailsIncluded, final Integer maxResults,
325321
final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
326322
throws StorageException {
327323
if (opContext == null) {
@@ -342,7 +338,7 @@ private ResultSegment<CloudFileShare> listSharesWithPrefixSegmented(final String
342338
}
343339

344340
private StorageRequest<CloudFileClient, Void, ResultSegment<CloudFileShare>> listSharesWithPrefixSegmentedImpl(
345-
final String prefix, final EnumSet<ShareListingDetails> detailsIncluded, final Integer maxResults,
341+
final String prefix, final ShareListingDetails detailsIncluded, final Integer maxResults,
346342
final FileRequestOptions options, final SegmentedStorageRequest segmentedRequest) {
347343

348344
Utility.assertContinuationType(segmentedRequest.getToken(), ResultContinuationType.SHARE);

microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileDirectory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,12 @@ public void signRequest(HttpURLConnection connection, CloudFileClient client, Op
529529
public Boolean preProcessResponse(CloudFileDirectory directory, CloudFileClient client,
530530
OperationContext context) throws Exception {
531531
if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) {
532-
// Set properties
533-
final FileDirectoryAttributes attributes =
534-
FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris());
535-
directory.setMetadata(attributes.getMetadata());
536-
directory.setProperties(attributes.getProperties());
532+
directory.updatePropertiesFromResponse(this.getConnection());
533+
// // Set properties
534+
// final FileDirectoryAttributes attributes =
535+
// FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris());
536+
// directory.setMetadata(attributes.getMetadata());
537+
// directory.setProperties(attributes.getProperties());
537538

538539
return Boolean.valueOf(true);
539540
}

microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileShare.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,11 @@ public void signRequest(HttpURLConnection connection, CloudFileClient client, Op
10191019
public Boolean preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context)
10201020
throws Exception {
10211021
if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) {
1022-
final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(),
1023-
client.isUsePathStyleUris());
1024-
share.metadata = attributes.getMetadata();
1025-
share.properties = attributes.getProperties();
1022+
share.updatePropertiesFromResponse(this.getConnection());
1023+
// final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(),
1024+
// client.isUsePathStyleUris());
1025+
// share.metadata = attributes.getMetadata();
1026+
// share.properties = attributes.getProperties();
10261027

10271028
return Boolean.valueOf(true);
10281029
}

microsoft-azure-storage/src/com/microsoft/azure/storage/file/FileRequest.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,7 @@ private static HttpURLConnection getProperties(final URI uri, final FileRequestO
640640
* @param listingContext
641641
* A set of parameters for the listing operation.
642642
* @param detailsIncluded
643-
* A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
644-
* whether share snapshots and/or metadata will be returned.
643+
* Additional details to return with the listing.
645644
* @return a HttpURLConnection configured for the operation.
646645
* @throws IOException
647646
* @throws URISyntaxException
@@ -650,28 +649,32 @@ private static HttpURLConnection getProperties(final URI uri, final FileRequestO
650649
*/
651650
public static HttpURLConnection listShares(final URI uri, final FileRequestOptions fileOptions,
652651
final OperationContext opContext, final ListingContext listingContext,
653-
final EnumSet<ShareListingDetails> detailsIncluded) throws URISyntaxException, IOException, StorageException {
652+
final ShareListingDetails detailsIncluded) throws URISyntaxException, IOException, StorageException {
654653
final UriQueryBuilder builder = BaseRequest.getListUriQueryBuilder(listingContext);
655654

656-
if (detailsIncluded != null && detailsIncluded.size() > 0) {
657-
final StringBuilder sb = new StringBuilder();
658-
boolean started = false;
655+
// if (detailsIncluded != null && detailsIncluded.size() > 0) {
656+
// final StringBuilder sb = new StringBuilder();
657+
// boolean started = false;
659658

660659
// if (detailsIncluded.contains(ShareListingDetails.SNAPSHOTS)) {
661660
// started = true;
662661
// sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME);
663662
// }
664663

665-
if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
666-
if (started)
667-
{
668-
sb.append(",");
669-
}
664+
// if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
665+
// if (started)
666+
// {
667+
// sb.append(",");
668+
// }
669+
//
670+
// sb.append(Constants.QueryConstants.METADATA);
671+
// }
670672

671-
sb.append(Constants.QueryConstants.METADATA);
672-
}
673+
// builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
674+
// }
673675

674-
builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
676+
if (detailsIncluded == ShareListingDetails.ALL || detailsIncluded == ShareListingDetails.METADATA) {
677+
builder.add(Constants.QueryConstants.INCLUDE, Constants.QueryConstants.METADATA);
675678
}
676679

677680
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);

microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListingDetails.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
*/
2020
public enum ShareListingDetails {
2121

22+
/**
23+
* Specifies including no additional details.
24+
*/
25+
NONE(0),
26+
27+
/**
28+
* Specifies including all available details.
29+
*/
30+
ALL(1),
31+
2232
/**
2333
* Specifies including share metadata.
2434
*/

0 commit comments

Comments
 (0)