diff --git a/BreakingChanges.txt b/BreakingChanges.txt index bc70b92ad6282..a8f72dff58062 100644 --- a/BreakingChanges.txt +++ b/BreakingChanges.txt @@ -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 diff --git a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileClientTests.java b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileClientTests.java index dedd08ac03270..f83e4d588d3a5 100644 --- a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileClientTests.java +++ b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileClientTests.java @@ -67,7 +67,7 @@ public void testListSharesTest() throws StorageException, URISyntaxException { do { ResultSegment 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(); @@ -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) { @@ -133,7 +133,7 @@ public void testListSharesWithSnapshot() throws StorageException, URISyntaxExcep share.uploadMetadata(); CloudFileClient client = FileTestHelper.createCloudFileClient(); - Iterable listResult = client.listShares(share.name, EnumSet.allOf(ShareListingDetails.class), null, null); + Iterable listResult = client.listShares(share.name, ShareListingDetails.ALL, null, null); int count = 0; boolean originalFound = false; diff --git a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileShareTests.java b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileShareTests.java index af3fb13d0477a..46a84aac4c581 100644 --- a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileShareTests.java +++ b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileShareTests.java @@ -318,7 +318,7 @@ public void testCloudFileShareUploadMetadata() throws StorageException, URISynta Assert.assertEquals("value2", this.share.getMetadata().get("key2")); Iterable 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()); diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileClient.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileClient.java index d6d3eb1a63330..409d4ff2730bf 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileClient.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileClient.java @@ -134,7 +134,7 @@ protected CloudFileShare getShareReference(final String shareName, String snapsh */ @DoesServiceRequest public Iterable listShares() { - return this.listSharesWithPrefix(null, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */); + return this.listSharesWithPrefix(null, ShareListingDetails.NONE, null /* options */, null /* opContext */); } /** @@ -149,7 +149,7 @@ public Iterable listShares() { */ @DoesServiceRequest public Iterable 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 */); } /** @@ -159,8 +159,7 @@ public Iterable listShares(final String prefix) { * @param prefix * A String that represents the share name prefix. * @param detailsIncluded - * A java.util.EnumSet 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 * null will use the default request options from the associated service client ( @@ -174,7 +173,7 @@ public Iterable listShares(final String prefix) { * shares for this client. */ @DoesServiceRequest - public Iterable listShares(final String prefix, final EnumSet detailsIncluded, + public Iterable listShares(final String prefix, final ShareListingDetails detailsIncluded, final FileRequestOptions options, final OperationContext opContext) { return this.listSharesWithPrefix(prefix, detailsIncluded, options, opContext); } @@ -190,7 +189,7 @@ public Iterable listShares(final String prefix, final EnumSet 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 */); } @@ -210,7 +209,7 @@ public ResultSegment listSharesSegmented() throws StorageExcepti */ @DoesServiceRequest public ResultSegment 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 */); } @@ -221,8 +220,7 @@ public ResultSegment listSharesSegmented(final String prefix) th * @param prefix * A String that represents the prefix of the share name. * @param detailsIncluded - * A java.util.EnumSet 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 null or greater * than 5000, the server will return up to 5,000 items. Must be at least 1. @@ -246,7 +244,7 @@ public ResultSegment listSharesSegmented(final String prefix) th */ @DoesServiceRequest public ResultSegment listSharesSegmented(final String prefix, - final EnumSet 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, @@ -260,8 +258,7 @@ public ResultSegment listSharesSegmented(final String prefix, * @param prefix * A String that represents the prefix of the share name. * @param detailsIncluded - * A java.util.EnumSet 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 * null will use the default request options from the associated service client ( @@ -275,7 +272,7 @@ public ResultSegment listSharesSegmented(final String prefix, * shares whose names begin with the specified prefix. */ private Iterable listSharesWithPrefix(final String prefix, - final EnumSet detailsIncluded, FileRequestOptions options, OperationContext opContext) { + final ShareListingDetails detailsIncluded, FileRequestOptions options, OperationContext opContext) { if (opContext == null) { opContext = new OperationContext(); } @@ -297,8 +294,7 @@ private Iterable listSharesWithPrefix(final String prefix, * @param prefix * A String that represents the prefix of the share name. * @param detailsIncluded - * A java.util.EnumSet 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 null or greater * than 5000, the server will return up to 5,000 items. Must be at least 1. @@ -321,7 +317,7 @@ private Iterable listSharesWithPrefix(final String prefix, * If a storage service error occurred. */ private ResultSegment listSharesWithPrefixSegmented(final String prefix, - final EnumSet detailsIncluded, final Integer maxResults, + final ShareListingDetails detailsIncluded, final Integer maxResults, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { @@ -342,7 +338,7 @@ private ResultSegment listSharesWithPrefixSegmented(final String } private StorageRequest> listSharesWithPrefixSegmentedImpl( - final String prefix, final EnumSet 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); diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileDirectory.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileDirectory.java index bc171cf4e422a..fcb275f32bcab 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileDirectory.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileDirectory.java @@ -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); } diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileShare.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileShare.java index fa13045161e7b..d3d180261010e 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileShare.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFileShare.java @@ -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); } diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/FileRequest.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/FileRequest.java index 746c5b5ce3ead..092f4866a6d62 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/FileRequest.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/FileRequest.java @@ -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 java.util.EnumSet 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 @@ -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 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); diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListingDetails.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListingDetails.java index 3e746585cf2da..87640da8982eb 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListingDetails.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListingDetails.java @@ -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. */