diff --git a/BreakingChanges.txt b/BreakingChanges.txt
index 8daeffb1454bc..80e1230416341 100644
--- a/BreakingChanges.txt
+++ b/BreakingChanges.txt
@@ -1,4 +1,10 @@
-Changes in X.X.X
+Changes in 6.0.0
+
+FILE
+* Many File service APIs can now throw a URISyntaxException.
+* Changed listShares() ShareListingDetails parameter to be an enum set like what is done for listing blobs.
+
+OTHER
* DefaultEndpointsProtocol will now be explicitly included in generated connection strings.
* Connection string parsing has been substantially re-written and expanded. Please refer to current documentation about connection string formats.
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 0d5b844f8df0e..0e1283665a48d 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,4 +1,6 @@
-X.X.X
+2017.10.06 Version 6.0.0
+ * Added support for taking a snapshot of a share.
+ * IOExceptions wrapping StorageExceptions will now contain the StorageException message in the outer exception.
* Connection string support expanded to allow AccountName to be specified with SharedAccessSignature and DefaultEndpointsProtocol. In this case, SharedAccessSignature is used for credentials, while having both DefaultEndpointsProtocol and AccountName allows the library to infer a set of default endpoints. Additionally, we have added support for BlobSecondaryEndpoint, QueueSecondaryEndpoint, TableSecondaryEndpoint, and FileSecondaryEndpoint. Specifying a secondary endpoint requires the specification of the corresponding primary.
* All: The use of DefaultEndpointsProtocol in a connection string is now optional in the case where endpoints would be automatically generated; if missing, a value of https will be inferred. When the parsed account settings in such a case are used to generate a connection string, the value of DefaultEndpointsProtocol will be explicitly included.
diff --git a/README.md b/README.md
index f0bff9df4c2ed..df9acf4fa0a06 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
com.microsoft.azure
azure-storage
- 5.5.0
+ 6.0.0
```
diff --git a/microsoft-azure-storage-samples/pom.xml b/microsoft-azure-storage-samples/pom.xml
index e1ddefbd90ec0..c697eb4e8dd54 100644
--- a/microsoft-azure-storage-samples/pom.xml
+++ b/microsoft-azure-storage-samples/pom.xml
@@ -26,7 +26,7 @@
com.microsoft.azure
azure-storage
- 5.5.0
+ 6.0.0
com.microsoft.azure
diff --git a/microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml b/microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml
index b129134f42437..f5c5d85d20a3c 100644
--- a/microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml
+++ b/microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml
@@ -26,7 +26,7 @@
com.microsoft.azure
azure-storage
- 5.5.0
+ 6.0.0
com.microsoft.azure
diff --git a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/EventFiringTests.java b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/EventFiringTests.java
index 6ee2236d86e86..b42ae25e8d938 100644
--- a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/EventFiringTests.java
+++ b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/EventFiringTests.java
@@ -20,14 +20,10 @@
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
-import org.apache.http.protocol.HTTP;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.net.HttpURLConnection;
-import java.net.SocketException;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -121,39 +117,46 @@ public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
}
});
- OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(new StorageEvent() {
+ StorageEvent globalResponseReceivedListener = new StorageEvent() {
@Override
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
fail("This event should not trigger");
}
- });
+ };
- assertEquals(0, callList.size());
- assertEquals(0, globalCallList.size());
+ try {
+ OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(globalResponseReceivedListener);
- CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
- CloudBlobContainer container = blobClient.getContainerReference("container1");
+ assertEquals(0, callList.size());
+ assertEquals(0, globalCallList.size());
- // make sure both update
- container.exists(null, null, eventContext);
- assertEquals(1, callList.size());
- assertEquals(1, globalCallList.size());
+ CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
+ CloudBlobContainer container = blobClient.getContainerReference("container1");
- // make sure only global updates
- container.exists();
- assertEquals(1, callList.size());
- assertEquals(2, globalCallList.size());
+ // make sure both update
+ container.exists(null, null, eventContext);
+ assertEquals(1, callList.size());
+ assertEquals(1, globalCallList.size());
- OperationContext
- .setGlobalResponseReceivedEventHandler(new StorageEventMultiCaster>());
- eventContext
- .setResponseReceivedEventHandler(new StorageEventMultiCaster>());
+ // make sure only global updates
+ container.exists();
+ assertEquals(1, callList.size());
+ assertEquals(2, globalCallList.size());
- // make sure neither update
- container.exists(null, null, eventContext);
- assertEquals(1, callList.size());
- assertEquals(2, globalCallList.size());
+ OperationContext
+ .setGlobalResponseReceivedEventHandler(new StorageEventMultiCaster>());
+ eventContext
+ .setResponseReceivedEventHandler(new StorageEventMultiCaster>());
+
+ // make sure neither update
+ container.exists(null, null, eventContext);
+ assertEquals(1, callList.size());
+ assertEquals(2, globalCallList.size());
+ }
+ finally {
+ OperationContext.getGlobalErrorReceivingResponseEventHandler().removeListener(globalResponseReceivedListener);
+ }
}
@Test
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 10a0c5986e123..17b38132224f6 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,
- ShareListingDetails.ALL, 15, token, null, null);
+ EnumSet.allOf(ShareListingDetails.class), 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, ShareListingDetails.ALL, i, null, null, null);
+ prefix, EnumSet.allOf(ShareListingDetails.class), i, null, null, null);
fail();
}
catch (IllegalArgumentException e) {
@@ -115,46 +115,50 @@ public void testListSharesMaxResultsValidationTest() throws StorageException, UR
assertNotNull(fileClient.listSharesSegmented("thereshouldntbeanyshareswiththisprefix"));
}
-// @Test
-// public void testListSharesWithSnapshot() throws StorageException, URISyntaxException {
-// CloudFileClient fileClient = FileTestHelper.createCloudFileClient();
-// CloudFileShare share = fileClient.getShareReference(UUID.randomUUID().toString());
-// share.create();
-//
-// HashMap shareMeta = new HashMap();
-// shareMeta.put("key1", "value1");
-// share.setMetadata(shareMeta);
-// share.uploadMetadata();
-//
-// CloudFileShare snapshot = share.createSnapshot();
-// HashMap meta2 = new HashMap();
-// meta2.put("key2", "value2");
-// share.setMetadata(meta2);
-// share.uploadMetadata();
-//
-// CloudFileClient client = FileTestHelper.createCloudFileClient();
-// Iterable listResult = client.listShares(share.name, ShareListingDetails.ALL, null, null);
-//
-// int count = 0;
-// boolean originalFound = false;
-// boolean snapshotFound = false;
-// for (CloudFileShare listShareItem : listResult) {
-// if (listShareItem.getName().equals(share.getName()) && !listShareItem.isSnapshot() && !originalFound)
-// {
-// count++;
-// originalFound = true;
-// assertEquals(share.getMetadata(), listShareItem.getMetadata());
-// assertEquals(share.getStorageUri(), listShareItem.getStorageUri());
-// }
-// else if (listShareItem.getName().equals(share.getName()) &&
-// listShareItem.isSnapshot() && !snapshotFound) {
-// count++;
-// snapshotFound = true;
-// assertEquals(snapshot.getMetadata(), listShareItem.getMetadata());
-// assertEquals(snapshot.getStorageUri(), listShareItem.getStorageUri());
-// }
-// }
-//
-// assertEquals(2, count);
-// }
+ @Test
+ public void testListSharesWithSnapshot() throws StorageException, URISyntaxException {
+ CloudFileClient fileClient = FileTestHelper.createCloudFileClient();
+ CloudFileShare share = fileClient.getShareReference(UUID.randomUUID().toString());
+ try {
+ share.create();
+
+ HashMap shareMeta = new HashMap();
+ shareMeta.put("key1", "value1");
+ share.setMetadata(shareMeta);
+ share.uploadMetadata();
+
+ CloudFileShare snapshot = share.createSnapshot();
+ HashMap meta2 = new HashMap();
+ meta2.put("key2", "value2");
+ share.setMetadata(meta2);
+ share.uploadMetadata();
+
+ CloudFileClient client = FileTestHelper.createCloudFileClient();
+ Iterable listResult = client.listShares(share.name, EnumSet.allOf(ShareListingDetails.class), null, null);
+
+ int count = 0;
+ boolean originalFound = false;
+ boolean snapshotFound = false;
+ for (CloudFileShare listShareItem : listResult) {
+ if (listShareItem.getName().equals(share.getName()) && !listShareItem.isSnapshot() && !originalFound) {
+ count++;
+ originalFound = true;
+ assertEquals(share.getMetadata(), listShareItem.getMetadata());
+ assertEquals(share.getStorageUri(), listShareItem.getStorageUri());
+ } else if (listShareItem.getName().equals(share.getName()) &&
+ listShareItem.isSnapshot() && !snapshotFound) {
+ count++;
+ snapshotFound = true;
+ assertEquals(snapshot.getMetadata(), listShareItem.getMetadata());
+ assertEquals(snapshot.getStorageUri(), listShareItem.getStorageUri());
+ }
+ }
+
+ assertEquals(2, count);
+ }
+ finally
+ {
+ share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
+ }
+ }
}
\ No newline at end of file
diff --git a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileDirectoryTests.java b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileDirectoryTests.java
index 32f70df70d413..92de13ae410f3 100644
--- a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileDirectoryTests.java
+++ b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileDirectoryTests.java
@@ -60,7 +60,7 @@ public void cloudFileDirectorySetUp() throws URISyntaxException, StorageExceptio
@After
public void cloudFileDirectoryTearDown() throws StorageException {
- this.share.deleteIfExists();
+ this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
}
/**
@@ -480,70 +480,70 @@ private static void testMetadataFailures(CloudFileDirectory directory, String ke
directory.getMetadata().remove(key);
}
-// @Test
-// public void testUnsupportedDirectoryApisWithinShareSnapshot() throws StorageException, URISyntaxException {
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFileDirectory rootDir = snapshot.getRootDirectoryReference();
-// try {
-// rootDir.create();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// rootDir.delete();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// rootDir.uploadMetadata();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-//
-// snapshot.delete();
-// }
-
-// @Test
-// public void testSupportedDirectoryApisInShareSnapshot() throws StorageException, URISyntaxException {
-// CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
-// dir.deleteIfExists();
-// dir.create();
-// HashMap meta = new HashMap();
-// meta.put("key1", "value1");
-// dir.setMetadata(meta);
-// dir.uploadMetadata();
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFileDirectory snapshotDir = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
-//
-// HashMap meta2 = new HashMap();
-// meta2.put("key2", "value2");
-// dir.setMetadata(meta2);
-// dir.uploadMetadata();
-// snapshotDir.downloadAttributes();
-//
-// assertTrue(snapshotDir.getMetadata().size() == 1 && snapshotDir.getMetadata().get("key1").equals("value1"));
-// assertNotNull(snapshotDir.getProperties().getEtag());
-//
-// dir.downloadAttributes();
-// assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2"));
-// assertNotNull(dir.getProperties().getEtag());
-// assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());
-//
-// final UriQueryBuilder uriBuilder = new UriQueryBuilder();
-// uriBuilder.add("sharesnapshot", snapshot.snapshotID);
-// uriBuilder.add("restype", "directory");
-// CloudFileDirectory snapshotDir2 = new CloudFileDirectory(uriBuilder.addToURI(dir.getUri()), this.share.getServiceClient().getCredentials());
-// assertEquals(snapshot.snapshotID, snapshotDir2.getShare().snapshotID);
-// assertTrue(snapshotDir2.exists());
-//
-// snapshot.delete();
-// }
+ @Test
+ public void testUnsupportedDirectoryApisWithinShareSnapshot() throws StorageException, URISyntaxException {
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFileDirectory rootDir = snapshot.getRootDirectoryReference();
+ try {
+ rootDir.create();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ rootDir.delete();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ rootDir.uploadMetadata();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+
+ snapshot.delete();
+ }
+
+ @Test
+ public void testSupportedDirectoryApisInShareSnapshot() throws StorageException, URISyntaxException {
+ CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
+ dir.deleteIfExists();
+ dir.create();
+ HashMap meta = new HashMap();
+ meta.put("key1", "value1");
+ dir.setMetadata(meta);
+ dir.uploadMetadata();
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFileDirectory snapshotDir = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
+
+ HashMap meta2 = new HashMap();
+ meta2.put("key2", "value2");
+ dir.setMetadata(meta2);
+ dir.uploadMetadata();
+ snapshotDir.downloadAttributes();
+
+ assertTrue(snapshotDir.getMetadata().size() == 1 && snapshotDir.getMetadata().get("key1").equals("value1"));
+ assertNotNull(snapshotDir.getProperties().getEtag());
+
+ dir.downloadAttributes();
+ assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2"));
+ assertNotNull(dir.getProperties().getEtag());
+ assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());
+
+ final UriQueryBuilder uriBuilder = new UriQueryBuilder();
+ uriBuilder.add("sharesnapshot", snapshot.snapshotID);
+ uriBuilder.add("restype", "directory");
+ CloudFileDirectory snapshotDir2 = new CloudFileDirectory(uriBuilder.addToURI(dir.getUri()), this.share.getServiceClient().getCredentials());
+ assertEquals(snapshot.snapshotID, snapshotDir2.getShare().snapshotID);
+ assertTrue(snapshotDir2.exists());
+
+ snapshot.delete();
+ }
/*
[TestMethod]
@@ -872,7 +872,7 @@ public void eventOccurred(SendingRequestEvent eventArg) {
directory.delete();
assertFalse(directory.exists());
}
- catch (StorageException e) {
+ catch (Exception e) {
fail("Delete should succeed.");
}
}
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 544adeb110414..1153923e4add1 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
@@ -62,7 +62,7 @@ public void fileShareTestMethodSetUp() throws StorageException, URISyntaxExcepti
@After
public void fileShareTestMethodTearDown() throws StorageException {
- this.share.deleteIfExists();
+ this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
}
/**
@@ -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(),
- ShareListingDetails.METADATA, null, null);
+ EnumSet.of(ShareListingDetails.METADATA), null, null);
for (CloudFileShare share3 : shares) {
Assert.assertEquals(2, share3.getMetadata().size());
@@ -494,195 +494,188 @@ public void eventOccurred(SendingRequestEvent eventArg) {
assertTrue(this.share.deleteIfExists(null, null, ctx));
}
-// @Test
-// public void testCreateShareSnapshot() throws StorageException, URISyntaxException, IOException {
-// // create share with metadata
-// this.share.create();
-// assertTrue(this.share.exists());
-// HashMap shareMeta = new HashMap();
-// shareMeta.put("key1", "value1");
-// this.share.setMetadata(shareMeta);
-// this.share.uploadMetadata();
-//
-// CloudFileDirectory dir1 = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
-// dir1.create();
-// CloudFile file1 = dir1.getFileReference("file1");
-// file1.create(1024);
-// ByteArrayInputStream srcStream = FileTestHelper.getRandomDataStream(1024);
-// file1.upload(srcStream, 1024);
-//
-// // create directory with metadata
-// HashMap dirMeta = new HashMap();
-// dirMeta.put("key2", "value2");
-// dir1.setMetadata(dirMeta);
-// dir1.uploadMetadata();
-//
-// // verify that exists() call on snapshot populates metadata
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFileClient client = FileTestHelper.createCloudFileClient();
-// CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
-// assertTrue(snapshotRef.exists());
-// assertTrue(snapshotRef.getMetadata().size() == 1 && snapshotRef.getMetadata().get("key1").equals("value1"));
-//
-// // verify that downloadAttributes() populates metadata
-// CloudFileShare snapshotRef2 = client.getShareReference(snapshot.name, snapshot.snapshotID);
-// snapshotRef2.downloadAttributes();
-// snapshot.downloadAttributes();
-// assertTrue(snapshotRef2.getMetadata().size() == 1 && snapshotRef2.getMetadata().get("key1").equals("value1"));
-// assertTrue(snapshot.getMetadata().size() == 1 && snapshot.getMetadata().get("key1").equals("value1"));
-//
-// // verify that exists() populates the metadata
-// CloudFileDirectory snapshotDir1 = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
-// snapshotDir1.exists();
-// assertTrue(snapshotDir1.getMetadata().size() == 1 && snapshotDir1.getMetadata().get("key2").equals("value2"));
-//
-// // verify that downloadAttributes() populates the metadata
-// CloudFileDirectory snapshotDir2 = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
-// snapshotDir2.downloadAttributes();
-// assertTrue(snapshotDir2.getMetadata().size() == 1 && snapshotDir2.getMetadata().get("key2").equals("value2"));
-//
-// // create snapshot with metadata
-// HashMap shareMeta2 = new HashMap();
-// shareMeta2.put("abc", "def");
-// CloudFileShare snapshotRef3 = this.share.createSnapshot(shareMeta2, null, null, null);
-// CloudFileShare snapshotRef4 = client.getShareReference(snapshotRef3.name, snapshotRef3.snapshotID);
-// assertTrue(snapshotRef4.exists());
-// assertTrue(snapshotRef4.getMetadata().size() == 1 && snapshotRef4.getMetadata().get("abc").equals("def"));
-//
-// final UriQueryBuilder uriBuilder = new UriQueryBuilder();
-// uriBuilder.add("sharesnapshot", snapshot.snapshotID);
-//// CloudFileShare snapshotRef5 = new CloudFileShare(uriBuilder.addToURI(this.share.getUri()),
-//// this.share.getServiceClient().getCredentials(), null);
-//// assertEquals(snapshot.snapshotID, snapshotRef5.snapshotID);
-//// assertTrue(snapshotRef5.exists());
-//
-// snapshot.delete();
-// }
+ @Test
+ public void testCreateShareSnapshot() throws StorageException, URISyntaxException, IOException {
+ // create share with metadata
+ this.share.create();
+ assertTrue(this.share.exists());
+ HashMap shareMeta = new HashMap();
+ shareMeta.put("key1", "value1");
+ this.share.setMetadata(shareMeta);
+ this.share.uploadMetadata();
+
+ CloudFileDirectory dir1 = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
+ dir1.create();
+ CloudFile file1 = dir1.getFileReference("file1");
+ file1.create(1024);
+ ByteArrayInputStream srcStream = FileTestHelper.getRandomDataStream(1024);
+ file1.upload(srcStream, 1024);
+
+ // create directory with metadata
+ HashMap dirMeta = new HashMap();
+ dirMeta.put("key2", "value2");
+ dir1.setMetadata(dirMeta);
+ dir1.uploadMetadata();
+
+ // verify that exists() call on snapshot populates metadata
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFileClient client = FileTestHelper.createCloudFileClient();
+ CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
+ assertTrue(snapshotRef.exists());
+ assertTrue(snapshotRef.getMetadata().size() == 1 && snapshotRef.getMetadata().get("key1").equals("value1"));
+
+ // verify that downloadAttributes() populates metadata
+ CloudFileShare snapshotRef2 = client.getShareReference(snapshot.name, snapshot.snapshotID);
+ snapshotRef2.downloadAttributes();
+ snapshot.downloadAttributes();
+ assertTrue(snapshotRef2.getMetadata().size() == 1 && snapshotRef2.getMetadata().get("key1").equals("value1"));
+ assertTrue(snapshot.getMetadata().size() == 1 && snapshot.getMetadata().get("key1").equals("value1"));
+
+ // verify that exists() populates the metadata
+ CloudFileDirectory snapshotDir1 = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
+ snapshotDir1.exists();
+ assertTrue(snapshotDir1.getMetadata().size() == 1 && snapshotDir1.getMetadata().get("key2").equals("value2"));
+
+ // verify that downloadAttributes() populates the metadata
+ CloudFileDirectory snapshotDir2 = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
+ snapshotDir2.downloadAttributes();
+ assertTrue(snapshotDir2.getMetadata().size() == 1 && snapshotDir2.getMetadata().get("key2").equals("value2"));
+
+ // create snapshot with metadata
+ HashMap shareMeta2 = new HashMap();
+ shareMeta2.put("abc", "def");
+ CloudFileShare snapshotRef3 = this.share.createSnapshot(shareMeta2, null, null, null);
+ CloudFileShare snapshotRef4 = client.getShareReference(snapshotRef3.name, snapshotRef3.snapshotID);
+ assertTrue(snapshotRef4.exists());
+ assertTrue(snapshotRef4.getMetadata().size() == 1 && snapshotRef4.getMetadata().get("abc").equals("def"));
+
+ final UriQueryBuilder uriBuilder = new UriQueryBuilder();
+ uriBuilder.add("sharesnapshot", snapshot.snapshotID);
+ CloudFileShare snapshotRef5 = new CloudFileShare(uriBuilder.addToURI(this.share.getUri()),
+ this.share.getServiceClient().getCredentials());
+ assertEquals(snapshot.snapshotID, snapshotRef5.snapshotID);
+ assertTrue(snapshotRef5.exists());
+
+ snapshot.delete();
+ }
-// @Test
-// public void testDeleteShareSnapshotOptions() throws StorageException, URISyntaxException, IOException {
-// // create share with metadata
-// this.share.create();
-// assertTrue(this.share.exists());
-//
-// // verify that exists() call on snapshot populates metadata
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFileClient client = FileTestHelper.createCloudFileClient();
-// CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
-// assertTrue(snapshotRef.exists());
-//
-// try {
-// share.delete();
-// }
-// catch (final StorageException e) {
-// assertEquals(StorageErrorCodeStrings.SHARE_HAS_SNAPSHOTS, e.getErrorCode());
-// }
-//
-// share.delete(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
-// assertFalse(share.exists());
-// assertFalse(snapshot.exists());
-// }
-
-// @Test
-// public void testListFilesAndDirectoriesWithinShareSnapshot() throws StorageException, URISyntaxException {
-// this.share.create();
-//
-// CloudFileDirectory myDir = this.share.getRootDirectoryReference().getDirectoryReference("mydir");
-// myDir.create();
-// myDir.getFileReference("myfile").create(1024);
-// myDir.getDirectoryReference("yourDir").create();
-// assertTrue(this.share.exists());
-//
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFileClient client = FileTestHelper.createCloudFileClient();
-// CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
-//
-// Iterable listResult = snapshotRef.getRootDirectoryReference().listFilesAndDirectories();
-// int count = 0;
-// for (ListFileItem listFileItem : listResult) {
-// count++;
-// assertEquals("mydir", ((CloudFileDirectory) listFileItem).getName());
-// }
-//
-// assertEquals(1, count);
-//
-// count = 0;
-// listResult = snapshotRef.getRootDirectoryReference().getDirectoryReference("mydir").listFilesAndDirectories();
-// for (ListFileItem listFileItem : listResult) {
-// if (listFileItem instanceof CloudFileDirectory) {
-// count++;
-// assertEquals("yourDir", ((CloudFileDirectory) listFileItem).getName());
-// }
-// else {
-// count++;
-// assertEquals("myfile", ((CloudFile) listFileItem).getName());
-// }
-// }
-//
-// assertEquals(2, count);
-//
-// snapshot.delete();
-// }
-
-// @Test
-// public void testUnsupportedApisShareSnapshot() throws StorageException, URISyntaxException {
-// CloudFileClient client = FileTestHelper.createCloudFileClient();
-// this.share.create();
-// this.share.downloadPermissions();
-// CloudFileShare snapshot = this.share.createSnapshot();
-// try {
-// snapshot.createSnapshot();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-//// try {
-//// new CloudFileShare(snapshot.getQualifiedUri(), client.getCredentials(), "2016-10-24T16:37:17.0000000Z");
-//// fail("Shouldn't get here");
-//// }
-//// catch (IllegalArgumentException e) {
-//// assertEquals(SR.SNAPSHOT_QUERY_OPTION_ALREADY_DEFINED, e.getMessage());
-//// }
-// try {
-// snapshot.downloadPermissions();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// snapshot.getStats();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// snapshot.uploadMetadata();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// FileSharePermissions permissions = new FileSharePermissions();
-// snapshot.uploadPermissions(permissions);
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// snapshot.uploadProperties();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-//
-// snapshot.delete();
-// }
+ @Test
+ public void testDeleteShareSnapshotOptions() throws StorageException, URISyntaxException, IOException {
+ // create share with metadata
+ this.share.create();
+ assertTrue(this.share.exists());
+
+ // verify that exists() call on snapshot populates metadata
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFileClient client = FileTestHelper.createCloudFileClient();
+ CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
+ assertTrue(snapshotRef.exists());
+
+ try {
+ share.delete();
+ }
+ catch (final StorageException e) {
+ assertEquals(StorageErrorCodeStrings.SHARE_HAS_SNAPSHOTS, e.getErrorCode());
+ }
+
+ share.delete(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
+ assertFalse(share.exists());
+ assertFalse(snapshot.exists());
+ }
+
+ @Test
+ public void testListFilesAndDirectoriesWithinShareSnapshot() throws StorageException, URISyntaxException {
+ this.share.create();
+
+ CloudFileDirectory myDir = this.share.getRootDirectoryReference().getDirectoryReference("mydir");
+ myDir.create();
+ myDir.getFileReference("myfile").create(1024);
+ myDir.getDirectoryReference("yourDir").create();
+ assertTrue(this.share.exists());
+
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFileClient client = FileTestHelper.createCloudFileClient();
+ CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
+
+ Iterable listResult = snapshotRef.getRootDirectoryReference().listFilesAndDirectories();
+ int count = 0;
+ for (ListFileItem listFileItem : listResult) {
+ count++;
+ assertEquals("mydir", ((CloudFileDirectory) listFileItem).getName());
+ }
+
+ assertEquals(1, count);
+
+ count = 0;
+ listResult = snapshotRef.getRootDirectoryReference().getDirectoryReference("mydir").listFilesAndDirectories();
+ for (ListFileItem listFileItem : listResult) {
+ if (listFileItem instanceof CloudFileDirectory) {
+ count++;
+ assertEquals("yourDir", ((CloudFileDirectory) listFileItem).getName());
+ }
+ else {
+ count++;
+ assertEquals("myfile", ((CloudFile) listFileItem).getName());
+ }
+ }
+
+ assertEquals(2, count);
+
+ snapshot.delete();
+ }
+
+ @Test
+ public void testUnsupportedApisShareSnapshot() throws StorageException, URISyntaxException {
+ CloudFileClient client = FileTestHelper.createCloudFileClient();
+ this.share.create();
+ this.share.downloadPermissions();
+ CloudFileShare snapshot = this.share.createSnapshot();
+ try {
+ snapshot.createSnapshot();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ snapshot.downloadPermissions();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ snapshot.getStats();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ snapshot.uploadMetadata();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ FileSharePermissions permissions = new FileSharePermissions();
+ snapshot.uploadPermissions(permissions);
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ snapshot.uploadProperties();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+
+ snapshot.delete();
+ }
private static void assertPermissionsEqual(FileSharePermissions expected, FileSharePermissions actual) {
HashMap expectedPolicies = expected.getSharedAccessPolicies();
diff --git a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileTests.java b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileTests.java
index f4737435992bc..b12ec11dcb1d3 100644
--- a/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileTests.java
+++ b/microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileTests.java
@@ -86,7 +86,7 @@ public void fileTestMethodSetUp() throws URISyntaxException, StorageException {
@After
public void fileTestMethodTearDown() throws StorageException {
- this.share.deleteIfExists();
+ this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
}
/**
@@ -1412,7 +1412,7 @@ public void eventOccurred(SendingRequestEvent eventArg) {
file.delete();
assertFalse(file.exists());
}
- catch (StorageException e) {
+ catch (Exception e) {
fail("Delete should succeed.");
}
}
@@ -1462,8 +1462,8 @@ public void testFileGetRangeContentMD5Bounds() throws StorageException, IOExcept
FileRequestOptions options = new FileRequestOptions();
OperationContext opContext = new OperationContext();
try {
- FileRequest.getFile(file.getUri(), options, opContext, null, 0L, 4L * Constants.MB, true);
- FileRequest.getFile(file.getUri(), options, opContext, null, 0L, 4L * Constants.MB + 1, true);
+ FileRequest.getFile(file.getUri(), options, opContext, null, null, 0L, 4L * Constants.MB, true);
+ FileRequest.getFile(file.getUri(), options, opContext, null, null, 0L, 4L * Constants.MB + 1, true);
fail("The request for range ContentMD5 should have thrown an Exception for exceeding the limit.");
}
catch (IllegalArgumentException e)
@@ -1617,103 +1617,103 @@ private void doCloudFileCopy(boolean sourceIsSas, boolean destinationIsSas)
source.delete();
}
-// @Test
-// public void testUnsupportedFileApisWithinShareSnapshot() throws StorageException, URISyntaxException {
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFile file = snapshot.getRootDirectoryReference().getFileReference("file");
-//
-// try {
-// file.create(1024);
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// file.delete();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// file.uploadMetadata();
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// file.abortCopy(null);
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// file.clearRange(0, 512);
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// file.startCopy(file);
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// }
-// try {
-// file.upload(null, 512);
-// fail("Shouldn't get here");
-// }
-// catch (IllegalArgumentException e) {
-// assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
-// } catch (IOException e) {
-// fail("Shouldn't get here");
-// }
-//
-// snapshot.delete();
-// }
-
-// @Test
-// public void testSupportedFileApisInShareSnapshot() throws StorageException, URISyntaxException, UnsupportedEncodingException {
-// CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
-// dir.deleteIfExists();
-// dir.create();
-// CloudFile file = dir.getFileReference("file");
-// file.create(1024);
-//
-// HashMap meta = new HashMap();
-// meta.put("key1", "value1");
-// file.setMetadata(meta);
-// file.uploadMetadata();
-//
-// CloudFileShare snapshot = this.share.createSnapshot();
-// CloudFile snapshotFile = snapshot.getRootDirectoryReference()
-// .getDirectoryReference("dir1").getFileReference("file");
-//
-// HashMap meta2 = new HashMap();
-// meta2.put("key2", "value2");
-// file.setMetadata(meta2);
-// file.uploadMetadata();
-// snapshotFile.downloadAttributes();
-//
-// assertTrue(snapshotFile.getMetadata().size() == 1 && snapshotFile.getMetadata().get("key1").equals("value1"));
-// assertNotNull(snapshotFile.getProperties().getEtag());
-//
-// file.downloadAttributes();
-// assertTrue(file.getMetadata().size() == 1 && file.getMetadata().get("key2").equals("value2"));
-// assertNotNull(file.getProperties().getEtag());
-// assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());
-//
-// final UriQueryBuilder uriBuilder = new UriQueryBuilder();
-// uriBuilder.add("sharesnapshot", snapshot.snapshotID);
-// CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials());
-// assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID);
-// assertTrue(snapshotFile2.exists());
-//
-// snapshot.delete();
-// }
+ @Test
+ public void testUnsupportedFileApisWithinShareSnapshot() throws StorageException, URISyntaxException {
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFile file = snapshot.getRootDirectoryReference().getFileReference("file");
+
+ try {
+ file.create(1024);
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ file.delete();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ file.uploadMetadata();
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ file.abortCopy(null);
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ file.clearRange(0, 512);
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ file.startCopy(file);
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ }
+ try {
+ file.upload(null, 512);
+ fail("Shouldn't get here");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
+ } catch (IOException e) {
+ fail("Shouldn't get here");
+ }
+
+ snapshot.delete();
+ }
+
+ @Test
+ public void testSupportedFileApisInShareSnapshot() throws StorageException, URISyntaxException, UnsupportedEncodingException {
+ CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
+ dir.deleteIfExists();
+ dir.create();
+ CloudFile file = dir.getFileReference("file");
+ file.create(1024);
+
+ HashMap meta = new HashMap();
+ meta.put("key1", "value1");
+ file.setMetadata(meta);
+ file.uploadMetadata();
+
+ CloudFileShare snapshot = this.share.createSnapshot();
+ CloudFile snapshotFile = snapshot.getRootDirectoryReference()
+ .getDirectoryReference("dir1").getFileReference("file");
+
+ HashMap meta2 = new HashMap();
+ meta2.put("key2", "value2");
+ file.setMetadata(meta2);
+ file.uploadMetadata();
+ snapshotFile.downloadAttributes();
+
+ assertTrue(snapshotFile.getMetadata().size() == 1 && snapshotFile.getMetadata().get("key1").equals("value1"));
+ assertNotNull(snapshotFile.getProperties().getEtag());
+
+ file.downloadAttributes();
+ assertTrue(file.getMetadata().size() == 1 && file.getMetadata().get("key2").equals("value2"));
+ assertNotNull(file.getProperties().getEtag());
+ assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());
+
+ final UriQueryBuilder uriBuilder = new UriQueryBuilder();
+ uriBuilder.add("sharesnapshot", snapshot.snapshotID);
+ CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials());
+ assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID);
+ assertTrue(snapshotFile2.exists());
+
+ snapshot.delete();
+ }
}
\ No newline at end of file
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java
index ccc010d05b6b8..69d063316a2b8 100644
--- a/microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java
@@ -661,7 +661,7 @@ public static class HeaderConstants {
/**
* Specifies the value to use for UserAgent header.
*/
- public static final String USER_AGENT_VERSION = "5.5.0";
+ public static final String USER_AGENT_VERSION = "6.0.0";
/**
* The default type for content-type and accept
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java
index 44ce349675219..ec370d5df2ef9 100644
--- a/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java
@@ -58,7 +58,7 @@ public static ServiceProperties readServicePropertiesFromStream(final InputStrea
IOException, ParserConfigurationException {
SAXParser saxParser = Utility.getSAXParser();
ServicePropertiesHandler handler = new ServicePropertiesHandler();
- handler.props.setCors(null);
+ handler.props.setLogging(null);
handler.props.setHourMetrics(null);
handler.props.setMinuteMetrics(null);
handler.props.setCors(null);
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/PremiumPageBlobTier.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/PremiumPageBlobTier.java
index 590a66c334f77..ffcc51670a58f 100644
--- a/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/PremiumPageBlobTier.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/blob/PremiumPageBlobTier.java
@@ -77,32 +77,35 @@ public enum PremiumPageBlobTier {
*
* @return A PremiumPageBlobTier
value that represents the premium page blob tier.
*/
- protected static PremiumPageBlobTier parse(final String premiumBlobTierString) {
+ protected static PremiumPageBlobTier parse(String premiumBlobTierString) {
+
if (Utility.isNullOrEmpty(premiumBlobTierString)) {
return UNKNOWN;
}
- else if ("p4".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+
+ premiumBlobTierString = premiumBlobTierString.toLowerCase(Locale.US);
+ if ("p4".equals(premiumBlobTierString)) {
return P4;
}
- else if ("p6".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p6".equals(premiumBlobTierString)) {
return P6;
}
- else if ("p10".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p10".equals(premiumBlobTierString)) {
return P10;
}
- else if ("p20".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p20".equals(premiumBlobTierString)) {
return P20;
}
- else if ("p30".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p30".equals(premiumBlobTierString)) {
return P30;
}
- else if ("p40".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p40".equals(premiumBlobTierString)) {
return P40;
}
- else if ("p50".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p50".equals(premiumBlobTierString)) {
return P50;
}
- else if ("p60".equals(premiumBlobTierString.toLowerCase(Locale.US))) {
+ else if ("p60".equals(premiumBlobTierString)) {
return P60;
}
else {
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java
index 731d55971b68e..8facaed5fc900 100644
--- a/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java
@@ -767,8 +767,15 @@ public static XMLStreamWriter createXMLStreamWriter(StringWriter outWriter) thro
* @return A java.io.IOException
object that represents the created IO exception.
*/
public static IOException initIOException(final Exception ex) {
- final IOException retEx = new IOException();
- retEx.initCause(ex);
+ String message = null;
+ if (ex != null && ex.getMessage() != null) {
+ message = ex.getMessage() + " Please see the cause for further information.";
+ }
+ else {
+ message = "Please see the cause for further information.";
+ }
+
+ final IOException retEx = new IOException(message, ex);
return retEx;
}
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFile.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFile.java
index 12063f87b5cb4..b22ece568cbc3 100644
--- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFile.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/CloudFile.java
@@ -155,8 +155,9 @@ public CloudFile(final StorageUri fileAbsoluteUri) throws StorageException, URIS
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
- public CloudFile(final URI fileAbsoluteUri, final StorageCredentials credentials) throws StorageException {
+ public CloudFile(final URI fileAbsoluteUri, final StorageCredentials credentials) throws StorageException, URISyntaxException {
this(new StorageUri(fileAbsoluteUri), credentials);
}
@@ -171,8 +172,9 @@ public CloudFile(final URI fileAbsoluteUri, final StorageCredentials credentials
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
- public CloudFile(final StorageUri fileAbsoluteUri, final StorageCredentials credentials) throws StorageException {
+ public CloudFile(final StorageUri fileAbsoluteUri, final StorageCredentials credentials) throws StorageException, URISyntaxException {
this.parseQueryAndVerify(fileAbsoluteUri, credentials);
}
@@ -230,9 +232,10 @@ protected CloudFile(final StorageUri uri, final String fileName, final CloudFile
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public final void abortCopy(final String copyId) throws StorageException {
+ public final void abortCopy(final String copyId) throws StorageException, URISyntaxException {
this.abortCopy(copyId, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -253,16 +256,17 @@ public final void abortCopy(final String copyId) throws StorageException {
* the operation.
*
* @throws StorageException
- * If a storage service error occurred.
+ * If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public final void abortCopy(final String copyId, final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -429,9 +433,10 @@ public final String startCopy(final CloudFile sourceFile, final AccessCondition
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public final String startCopy(final URI source) throws StorageException {
+ public final String startCopy(final URI source) throws StorageException, URISyntaxException {
return this.startCopy(source, null /* sourceAccessCondition */,
null /* destinationAccessCondition */, null /* options */, null /* opContext */);
}
@@ -459,17 +464,18 @@ public final String startCopy(final URI source) throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*
*/
@DoesServiceRequest
public final String startCopy(final URI source, final AccessCondition sourceAccessCondition,
final AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext)
- throws StorageException {
+ throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -539,9 +545,10 @@ public String preProcessResponse(CloudFile file, CloudFileClient client, Operati
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void clearRange(final long offset, final long length) throws StorageException {
+ public void clearRange(final long offset, final long length) throws StorageException, URISyntaxException {
this.clearRange(offset, length, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -568,15 +575,16 @@ public void clearRange(final long offset, final long length) throws StorageExcep
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void clearRange(final long offset, final long length, final AccessCondition accessCondition,
- FileRequestOptions options, OperationContext opContext) throws StorageException {
+ FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -593,10 +601,11 @@ public void clearRange(final long offset, final long length, final AccessConditi
* A long
which represents the size, in bytes, of the file.
*
* @throws StorageException
- * If a storage service error occurred.
+ * If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void create(final long size) throws StorageException {
+ public void create(final long size) throws StorageException, URISyntaxException {
this.create(size, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -619,16 +628,17 @@ public void create(final long size) throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void create(final long size, final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -682,9 +692,10 @@ public Void preProcessResponse(CloudFile file, CloudFileClient client, Operation
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public final void delete() throws StorageException {
+ public final void delete() throws StorageException, URISyntaxException {
this.delete(null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -704,15 +715,16 @@ public final void delete() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public final void delete(final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -728,9 +740,11 @@ public final void delete(final AccessCondition accessCondition, FileRequestOptio
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
+ *
*/
@DoesServiceRequest
- public final boolean deleteIfExists() throws StorageException {
+ public final boolean deleteIfExists() throws StorageException, URISyntaxException {
return this.deleteIfExists(null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -752,12 +766,13 @@ public final boolean deleteIfExists() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public final boolean deleteIfExists(final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
boolean exists = this.exists(true, accessCondition, options, opContext);
if (exists) {
@@ -1276,7 +1291,7 @@ public void setRequestLocationMode() {
public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, OperationContext context)
throws Exception {
return FileRequest.getFileRanges(file.getTransformedAddress(context).getUri(this.getCurrentLocation()),
- options, context, accessCondition);
+ options, context, accessCondition, file.getShare().snapshotID);
}
@Override
@@ -1343,7 +1358,7 @@ public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, Op
// : accessCondition;
return FileRequest.getFile(file.getTransformedAddress(context).getUri(this.getCurrentLocation()),
- options, context, accessCondition, this.getOffset(), this.getLength(),
+ options, context, accessCondition, file.getShare().snapshotID, this.getOffset(), this.getLength(),
(options.getUseTransactionalContentMD5() && !this.getArePropertiesPopulated()));
}
@@ -1518,7 +1533,7 @@ public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, Op
throws Exception {
return FileRequest.getFileProperties(
file.getTransformedAddress(context).getUri(this.getCurrentLocation()),
- options, context, accessCondition);
+ options, context, accessCondition, file.getShare().snapshotID);
}
@Override
@@ -1615,7 +1630,7 @@ public HttpURLConnection buildRequest(CloudFileClient client, CloudFile file, Op
throws Exception {
return FileRequest.getFileProperties(
file.getTransformedAddress(context).getUri(this.getCurrentLocation()),
- options, context, accessCondition);
+ options, context, accessCondition, file.getShare().snapshotID);
}
@Override
@@ -1837,9 +1852,10 @@ public final FileInputStream openRead(final AccessCondition accessCondition, Fil
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public FileOutputStream openWriteExisting() throws StorageException {
+ public FileOutputStream openWriteExisting() throws StorageException, URISyntaxException {
return this
.openOutputStreamInternal(null /* length */, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -1863,10 +1879,11 @@ public FileOutputStream openWriteExisting() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public FileOutputStream openWriteExisting(AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
return this.openOutputStreamInternal(null /* length */, accessCondition, options, opContext);
}
@@ -1885,9 +1902,10 @@ public FileOutputStream openWriteExisting(AccessCondition accessCondition, FileR
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public FileOutputStream openWriteNew(final long length) throws StorageException {
+ public FileOutputStream openWriteNew(final long length) throws StorageException, URISyntaxException {
return this
.openOutputStreamInternal(length, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -1917,10 +1935,11 @@ public FileOutputStream openWriteNew(final long length) throws StorageException
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public FileOutputStream openWriteNew(final long length, AccessCondition accessCondition,
- FileRequestOptions options, OperationContext opContext) throws StorageException {
+ FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
return openOutputStreamInternal(length, accessCondition, options, opContext);
}
@@ -1947,14 +1966,15 @@ public FileOutputStream openWriteNew(final long length, AccessCondition accessCo
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
private FileOutputStream openOutputStreamInternal(Long length, AccessCondition accessCondition,
- FileRequestOptions options, OperationContext opContext) throws StorageException {
+ FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient, false /* setStartTime */);
@@ -1990,9 +2010,10 @@ private FileOutputStream openOutputStreamInternal(Long length, AccessCondition a
* @throws StorageException
* If a storage service error occurred.
* @throws IOException
+ * @throws URISyntaxException
*/
public void uploadFromByteArray(final byte[] buffer, final int offset, final int length) throws StorageException,
- IOException {
+ IOException, URISyntaxException {
uploadFromByteArray(buffer, offset, length, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -2019,10 +2040,11 @@ public void uploadFromByteArray(final byte[] buffer, final int offset, final int
* @throws StorageException
* If a storage service error occurred.
* @throws IOException
+ * @throws URISyntaxException
*/
public void uploadFromByteArray(final byte[] buffer, final int offset, final int length,
final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
- throws StorageException, IOException {
+ throws StorageException, IOException, URISyntaxException {
ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer, offset, length);
this.upload(inputStream, length, accessCondition, options, opContext);
inputStream.close();
@@ -2037,8 +2059,9 @@ public void uploadFromByteArray(final byte[] buffer, final int offset, final int
* @throws StorageException
* If a storage service error occurred.
* @throws IOException
+ * @throws URISyntaxException
*/
- public void uploadFromFile(final String path) throws StorageException, IOException {
+ public void uploadFromFile(final String path) throws StorageException, IOException, URISyntaxException {
uploadFromFile(path, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -2061,9 +2084,10 @@ public void uploadFromFile(final String path) throws StorageException, IOExcepti
* @throws StorageException
* If a storage service error occurred.
* @throws IOException
+ * @throws URISyntaxException
*/
public void uploadFromFile(final String path, final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException, IOException {
+ OperationContext opContext) throws StorageException, IOException, URISyntaxException {
File file = new File(path);
long fileLength = file.length();
InputStream inputStream = new BufferedInputStream(new java.io.FileInputStream(file));
@@ -2081,8 +2105,9 @@ public void uploadFromFile(final String path, final AccessCondition accessCondit
* @throws StorageException
* If a storage service error occurred.
* @throws IOException
+ * @throws URISyntaxException
*/
- public void uploadText(final String content) throws StorageException, IOException {
+ public void uploadText(final String content) throws StorageException, IOException, URISyntaxException {
this.uploadText(content, null /* charsetName */, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -2109,9 +2134,10 @@ public void uploadText(final String content) throws StorageException, IOExceptio
* @throws StorageException
* If a storage service error occurred.
* @throws IOException
+ * @throws URISyntaxException
*/
public void uploadText(final String content, final String charsetName, final AccessCondition accessCondition,
- FileRequestOptions options, OperationContext opContext) throws StorageException, IOException {
+ FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException {
byte[] bytes = (charsetName == null) ? content.getBytes() : content.getBytes(charsetName);
this.uploadFromByteArray(bytes, 0, bytes.length, accessCondition, options, opContext);
}
@@ -2131,10 +2157,11 @@ public void uploadText(final String content, final String charsetName, final Acc
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void uploadRange(final InputStream sourceStream, final long offset, final long length)
- throws StorageException, IOException {
+ throws StorageException, IOException, URISyntaxException {
this.uploadRange(sourceStream, offset, length, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -2163,16 +2190,17 @@ public void uploadRange(final InputStream sourceStream, final long offset, final
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void uploadRange(final InputStream sourceStream, final long offset, final long length,
final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
- throws StorageException, IOException {
+ throws StorageException, IOException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -2302,9 +2330,10 @@ public Void preProcessResponse(CloudFile file, CloudFileClient client, Operation
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public final void uploadMetadata() throws StorageException {
+ public final void uploadMetadata() throws StorageException, URISyntaxException {
this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -2328,16 +2357,17 @@ public final void uploadMetadata() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public final void uploadMetadata(final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -2395,9 +2425,10 @@ public Void preProcessResponse(CloudFile file, CloudFileClient client, Operation
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public final void uploadProperties() throws StorageException {
+ public final void uploadProperties() throws StorageException, URISyntaxException {
this.uploadProperties(null /* accessCondition */, null /* options */, null /*opContext */);
}
@@ -2420,15 +2451,16 @@ public final void uploadProperties() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public final void uploadProperties(final AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -2482,8 +2514,9 @@ public Void preProcessResponse(CloudFile file, CloudFileClient client, Operation
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
- public void resize(long size) throws StorageException {
+ public void resize(long size) throws StorageException, URISyntaxException {
this.resize(size, null /* accessCondition */, null /* options */, null /* operationContext */);
}
@@ -2505,14 +2538,15 @@ public void resize(long size) throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
public void resize(long size, AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -2569,9 +2603,10 @@ public Void preProcessResponse(CloudFile file, CloudFileClient client, Operation
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException {
+ public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException, URISyntaxException {
this.upload(sourceStream, length, null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -2598,16 +2633,17 @@ public void upload(final InputStream sourceStream, final long length) throws Sto
* @throws IOException
* If an I/O exception occurred.
* @throws StorageException
- * If a storage service error occurred.
+ * If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition,
- FileRequestOptions options, OperationContext opContext) throws StorageException, IOException {
+ FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -2697,9 +2733,10 @@ protected static String getParentNameFromURI(final StorageUri resourceAddress, f
* A {@link StorageCredentials} object used to authenticate access.
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
private void parseQueryAndVerify(final StorageUri completeUri, final StorageCredentials credentials)
- throws StorageException {
+ throws StorageException, URISyntaxException {
Utility.assertNotNull("completeUri", completeUri);
if (!completeUri.isAbsolute()) {
@@ -2725,12 +2762,12 @@ private void parseQueryAndVerify(final StorageUri completeUri, final StorageCred
throw Utility.generateNewUnexpectedStorageException(e);
}
-// final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
+ final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
-// final String[] snapshotIDs = queryParameters.get(Constants.QueryConstants.SHARE_SNAPSHOT);
-// if (snapshotIDs != null && snapshotIDs.length > 0) {
-// this.getShare().snapshotID = snapshotIDs[0];
-// }
+ final String[] snapshotIDs = queryParameters.get(Constants.QueryConstants.SHARE_SNAPSHOT);
+ if (snapshotIDs != null && snapshotIDs.length > 0) {
+ this.getShare().snapshotID = snapshotIDs[0];
+ }
}
protected void updateEtagAndLastModifiedFromResponse(HttpURLConnection request) {
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 4b3fb37aff472..078c00849dcc8 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
@@ -101,30 +101,30 @@ public CloudFileClient(StorageUri storageUri, StorageCredentials credentials) {
*/
public CloudFileShare getShareReference(final String shareName) throws URISyntaxException, StorageException {
Utility.assertNotNullOrEmpty("shareName", shareName);
- return new CloudFileShare(shareName, this);
+ return this.getShareReference(shareName, null);
}
-// /**
-// * Gets a {@link CloudFileShare} object with the specified name.
-// *
-// * @param shareName
-// * The name of the share, which must adhere to share naming rules. The share name should not
-// * include any path separator characters (/).
-// * Share names must be lowercase, between 3-63 characters long and must start with a letter or
-// * number. Share names may contain only letters, numbers, and the dash (-) character.
-// * @param snapshotID
-// * A String
that represents the snapshot ID of the share.
-// * @return A reference to a {@link CloudFileShare} object.
-// * @throws StorageException
-// * @throws URISyntaxException
-// *
-// * @see Naming and Referencing Shares,
-// * Directories, Files, and Metadata
-// */
-// protected CloudFileShare getShareReference(final String shareName, String snapshotID) throws URISyntaxException, StorageException {
-// Utility.assertNotNullOrEmpty("shareName", shareName);
-// return new CloudFileShare(shareName, snapshotID, this);
-// }
+ /**
+ * Gets a {@link CloudFileShare} object with the specified name.
+ *
+ * @param shareName
+ * The name of the share, which must adhere to share naming rules. The share name should not
+ * include any path separator characters (/).
+ * Share names must be lowercase, between 3-63 characters long and must start with a letter or
+ * number. Share names may contain only letters, numbers, and the dash (-) character.
+ * @param snapshotID
+ * A String
that represents the snapshot ID of the share.
+ * @return A reference to a {@link CloudFileShare} object.
+ * @throws StorageException
+ * @throws URISyntaxException
+ *
+ * @see Naming and Referencing Shares,
+ * Directories, Files, and Metadata
+ */
+ public CloudFileShare getShareReference(final String shareName, String snapshotID) throws URISyntaxException, StorageException {
+ Utility.assertNotNullOrEmpty("shareName", shareName);
+ return new CloudFileShare(shareName, snapshotID, this);
+ }
/**
* Returns an enumerable collection of shares for this File service client.
@@ -134,7 +134,7 @@ public CloudFileShare getShareReference(final String shareName) throws URISyntax
*/
@DoesServiceRequest
public Iterable listShares() {
- return this.listSharesWithPrefix(null, ShareListingDetails.NONE, null /* options */, null /* opContext */);
+ return this.listSharesWithPrefix(null, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */);
}
/**
@@ -149,7 +149,7 @@ public Iterable listShares() {
*/
@DoesServiceRequest
public Iterable listShares(final String prefix) {
- return this.listSharesWithPrefix(prefix, ShareListingDetails.NONE, null /* options */, null /* opContext */);
+ return this.listSharesWithPrefix(prefix, EnumSet.noneOf(ShareListingDetails.class), null /* options */, null /* opContext */);
}
/**
@@ -159,7 +159,8 @@ public Iterable listShares(final String prefix) {
* @param prefix
* A String
that represents the share name prefix.
* @param detailsIncluded
- * A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
+ * A java.util.EnumSet
object that contains {@link ShareListingDetails} values that indicate
+ * whether share snapshots and/or 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 (
@@ -173,7 +174,7 @@ public Iterable listShares(final String prefix) {
* shares for this client.
*/
@DoesServiceRequest
- public Iterable listShares(final String prefix, final ShareListingDetails detailsIncluded,
+ public Iterable listShares(final String prefix, final EnumSet detailsIncluded,
final FileRequestOptions options, final OperationContext opContext) {
return this.listSharesWithPrefix(prefix, detailsIncluded, options, opContext);
}
@@ -189,7 +190,7 @@ public Iterable listShares(final String prefix, final ShareListi
*/
@DoesServiceRequest
public ResultSegment listSharesSegmented() throws StorageException {
- return this.listSharesSegmented(null, ShareListingDetails.NONE, null, null /* continuationToken */,
+ return this.listSharesSegmented(null, EnumSet.noneOf(ShareListingDetails.class), null, null /* continuationToken */,
null /* options */, null /* opContext */);
}
@@ -209,7 +210,7 @@ public ResultSegment listSharesSegmented() throws StorageExcepti
*/
@DoesServiceRequest
public ResultSegment listSharesSegmented(final String prefix) throws StorageException {
- return this.listSharesWithPrefixSegmented(prefix, ShareListingDetails.NONE, null, null /* continuationToken */,
+ return this.listSharesWithPrefixSegmented(prefix, EnumSet.noneOf(ShareListingDetails.class), null, null /* continuationToken */,
null /* options */, null /* opContext */);
}
@@ -220,7 +221,8 @@ public ResultSegment listSharesSegmented(final String prefix) th
* @param prefix
* A String
that represents the prefix of the share name.
* @param detailsIncluded
- * A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
+ * A java.util.EnumSet
object that contains {@link ShareListingDetails} values that indicate
+ * whether share snapshots and/or 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.
@@ -244,7 +246,7 @@ public ResultSegment listSharesSegmented(final String prefix) th
*/
@DoesServiceRequest
public ResultSegment listSharesSegmented(final String prefix,
- final ShareListingDetails detailsIncluded, final Integer maxResults,
+ final EnumSet detailsIncluded, final Integer maxResults,
final ResultContinuation continuationToken, final FileRequestOptions options,
final OperationContext opContext) throws StorageException {
return this.listSharesWithPrefixSegmented(prefix, detailsIncluded, maxResults, continuationToken, options,
@@ -258,7 +260,8 @@ public ResultSegment listSharesSegmented(final String prefix,
* @param prefix
* A String
that represents the prefix of the share name.
* @param detailsIncluded
- * A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
+ * A java.util.EnumSet
object that contains {@link ShareListingDetails} values that indicate
+ * whether share snapshots and/or 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 (
@@ -272,7 +275,7 @@ public ResultSegment listSharesSegmented(final String prefix,
* shares whose names begin with the specified prefix.
*/
private Iterable listSharesWithPrefix(final String prefix,
- final ShareListingDetails detailsIncluded, FileRequestOptions options, OperationContext opContext) {
+ final EnumSet detailsIncluded, FileRequestOptions options, OperationContext opContext) {
if (opContext == null) {
opContext = new OperationContext();
}
@@ -294,7 +297,8 @@ private Iterable listSharesWithPrefix(final String prefix,
* @param prefix
* A String
that represents the prefix of the share name.
* @param detailsIncluded
- * A {@link ShareListingDetails} value that indicates whether share metadata will be returned.
+ * A java.util.EnumSet
object that contains {@link ShareListingDetails} values that indicate
+ * whether share snapshots and/or 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.
@@ -317,7 +321,7 @@ private Iterable listSharesWithPrefix(final String prefix,
* If a storage service error occurred.
*/
private ResultSegment listSharesWithPrefixSegmented(final String prefix,
- final ShareListingDetails detailsIncluded, final Integer maxResults,
+ final EnumSet detailsIncluded, final Integer maxResults,
final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
@@ -338,7 +342,7 @@ private ResultSegment listSharesWithPrefixSegmented(final String
}
private StorageRequest> listSharesWithPrefixSegmentedImpl(
- final String prefix, final ShareListingDetails detailsIncluded, final Integer maxResults,
+ final String prefix, final EnumSet 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 3507b014805e9..b671958cee783 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
@@ -95,8 +95,9 @@ public final class CloudFileDirectory implements ListFileItem {
* @param directoryAbsoluteUri
* A {@link URI} that represents the file directory's address.
* @throws StorageException
+ * @throws URISyntaxException
*/
- public CloudFileDirectory(final URI directoryAbsoluteUri) throws StorageException {
+ public CloudFileDirectory(final URI directoryAbsoluteUri) throws StorageException, URISyntaxException {
this(new StorageUri(directoryAbsoluteUri));
}
@@ -106,8 +107,9 @@ public CloudFileDirectory(final URI directoryAbsoluteUri) throws StorageExceptio
* @param directoryAbsoluteUri
* A {@link StorageUri} that represents the file directory's address.
* @throws StorageException
+ * @throws URISyntaxException
*/
- public CloudFileDirectory(final StorageUri directoryAbsoluteUri) throws StorageException {
+ public CloudFileDirectory(final StorageUri directoryAbsoluteUri) throws StorageException, URISyntaxException {
this(directoryAbsoluteUri, (StorageCredentials) null);
}
@@ -120,9 +122,10 @@ public CloudFileDirectory(final StorageUri directoryAbsoluteUri) throws StorageE
* @param credentials
* A {@link StorageCredentials} object used to authenticate access.
* @throws StorageException
+ * @throws URISyntaxException
*/
public CloudFileDirectory(final URI directoryAbsoluteUri, final StorageCredentials credentials)
- throws StorageException {
+ throws StorageException, URISyntaxException {
this(new StorageUri(directoryAbsoluteUri), credentials);
}
@@ -135,9 +138,10 @@ public CloudFileDirectory(final URI directoryAbsoluteUri, final StorageCredentia
* @param credentials
* A {@link StorageCredentials} object used to authenticate access.
* @throws StorageException
+ * @throws URISyntaxException
*/
public CloudFileDirectory(final StorageUri directoryAbsoluteUri, final StorageCredentials credentials)
- throws StorageException {
+ throws StorageException, URISyntaxException {
this.parseQueryAndVerify(directoryAbsoluteUri, credentials);
}
@@ -168,9 +172,10 @@ protected CloudFileDirectory(final StorageUri uri, final String directoryName, f
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void create() throws StorageException {
+ public void create() throws StorageException, URISyntaxException {
this.create(null /* options */, null /* opContext */);
}
@@ -188,14 +193,15 @@ public void create() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void create(FileRequestOptions options, OperationContext opContext) throws StorageException {
+ public void create(FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -254,9 +260,10 @@ public Void preProcessResponse(CloudFileDirectory directory, CloudFileClient cli
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public boolean createIfNotExists() throws StorageException {
+ public boolean createIfNotExists() throws StorageException, URISyntaxException {
return this.createIfNotExists(null /* options */, null /* opContext */);
}
@@ -276,12 +283,13 @@ public boolean createIfNotExists() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext) throws StorageException {
+ public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
boolean exists = this.exists(true /* primaryOnly */, null /* accessCondition */, options, opContext);
if (exists) {
@@ -309,9 +317,10 @@ public boolean createIfNotExists(FileRequestOptions options, OperationContext op
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void delete() throws StorageException {
+ public void delete() throws StorageException, URISyntaxException {
this.delete(null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -331,15 +340,16 @@ public void delete() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void delete(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
- throws StorageException {
+ throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -386,9 +396,10 @@ public Void preProcessResponse(CloudFileDirectory directory, CloudFileClient cli
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public boolean deleteIfExists() throws StorageException {
+ public boolean deleteIfExists() throws StorageException, URISyntaxException {
return this.deleteIfExists(null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -410,10 +421,11 @@ public boolean deleteIfExists() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options,
- OperationContext opContext) throws StorageException {
+ OperationContext opContext) throws StorageException, URISyntaxException {
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
boolean exists = this.exists(true /* primaryOnly */, accessCondition, options, opContext);
@@ -506,7 +518,7 @@ public HttpURLConnection buildRequest(CloudFileClient client, CloudFileDirectory
OperationContext context) throws Exception {
return FileRequest.getDirectoryProperties(
directory.getTransformedAddress().getUri(this.getCurrentLocation()), options, context,
- accessCondition);
+ accessCondition, directory.getShare().snapshotID);
}
@Override
@@ -520,11 +532,11 @@ public Boolean preProcessResponse(CloudFileDirectory directory, CloudFileClient
OperationContext context) throws Exception {
if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) {
directory.updatePropertiesFromResponse(this.getConnection());
-// // Set properties
-// final FileDirectoryAttributes attributes =
-// FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris());
-// directory.setMetadata(attributes.getMetadata());
-// directory.setProperties(attributes.getProperties());
+ // Set properties
+ final FileDirectoryAttributes attributes =
+ FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris());
+ directory.setMetadata(attributes.getMetadata());
+ directory.setProperties(attributes.getProperties());
return Boolean.valueOf(true);
}
@@ -560,9 +572,10 @@ private void updatePropertiesFromResponse(HttpURLConnection request) {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
- public void uploadMetadata() throws StorageException {
+ public void uploadMetadata() throws StorageException, URISyntaxException {
this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */);
}
@@ -582,15 +595,16 @@ public void uploadMetadata() throws StorageException {
*
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
@DoesServiceRequest
public void uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
- throws StorageException {
+ throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
- //this.getShare().assertNoSnapshot();
+ this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -696,7 +710,7 @@ public HttpURLConnection buildRequest(CloudFileClient client, CloudFileDirectory
OperationContext context) throws Exception {
return FileRequest.getDirectoryProperties(
directory.getTransformedAddress().getUri(this.getCurrentLocation()), options, context,
- accessCondition);
+ accessCondition, directory.getShare().snapshotID);
}
@Override
@@ -917,7 +931,7 @@ public HttpURLConnection buildRequest(CloudFileClient client, CloudFileDirectory
.getNextMarker() : null);
return FileRequest.listFilesAndDirectories(
directory.getTransformedAddress().getUri(this.getCurrentLocation()),
- options, context, listingContext);
+ options, context, listingContext, directory.getShare().snapshotID);
}
@Override
@@ -1153,9 +1167,10 @@ protected void setStorageUri(final StorageUri storageUri) {
* A {@link StorageCredentials} object used to authenticate access.
* @throws StorageException
* If a storage service error occurred.
+ * @throws URISyntaxException
*/
private void parseQueryAndVerify(final StorageUri completeUri, final StorageCredentials credentials)
- throws StorageException {
+ throws StorageException, URISyntaxException {
Utility.assertNotNull("completeUri", completeUri);
if (!completeUri.isAbsolute()) {
@@ -1181,12 +1196,12 @@ private void parseQueryAndVerify(final StorageUri completeUri, final StorageCred
throw Utility.generateNewUnexpectedStorageException(e);
}
-// final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
-//
-// final String[] snapshotIDs = queryParameters.get(Constants.QueryConstants.SHARE_SNAPSHOT);
-// if (snapshotIDs != null && snapshotIDs.length > 0) {
-// this.getShare().snapshotID = snapshotIDs[0];
-// }
+ final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
+
+ final String[] snapshotIDs = queryParameters.get(Constants.QueryConstants.SHARE_SNAPSHOT);
+ if (snapshotIDs != null && snapshotIDs.length > 0) {
+ this.getShare().snapshotID = snapshotIDs[0];
+ }
}
/**
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 20b618ccb568e..1790b5a1afde3 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
@@ -81,7 +81,7 @@ public final class CloudFileShare {
/**
* Holds the snapshot ID.
*/
- //String snapshotID;
+ String snapshotID;
/**
* Holds a reference to the associated service client.
@@ -111,14 +111,14 @@ public final class CloudFileShare {
* @see Naming and Referencing Shares,
* Directories, Files, and Metadata
*/
- protected CloudFileShare(final String shareName, /*String snapshotID,*/ final CloudFileClient client) throws URISyntaxException,
+ public CloudFileShare(final String shareName, String snapshotID, final CloudFileClient client) throws URISyntaxException,
StorageException {
Utility.assertNotNull("client", client);
Utility.assertNotNull("shareName", shareName);
this.storageUri = PathUtility.appendPathToUri(client.getStorageUri(), shareName);
this.name = shareName;
- //this.snapshotID = snapshotID;
+ this.snapshotID = snapshotID;
this.fileServiceClient = client;
}
@@ -155,6 +155,8 @@ public CloudFileShare(final StorageUri storageUri) throws StorageException {
* A java.net.URI
object that represents the absolute URI of the share.
* @param credentials
* A {@link StorageCredentials} object used to authenticate access.
+ * @param snapshotID
+ * A String
that represents the snapshot version, if applicable.
*
* @throws StorageException
* If a storage service error occurred.
@@ -220,7 +222,7 @@ public void create(FileRequestOptions options, OperationContext opContext) throw
opContext = new OperationContext();
}
- //assertNoSnapshot();
+ assertNoSnapshot();
if (this.properties != null && this.properties.getShareQuota() != null) {
Utility.assertInBounds("Share Quota", this.properties.getShareQuota(), 1, FileConstants.MAX_SHARE_QUOTA);
}
@@ -393,7 +395,7 @@ public void delete(AccessCondition accessCondition, FileRequestOptions options,
* If a storage service error occurred.
*/
@DoesServiceRequest
- protected void delete(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
+ public void delete(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
@@ -416,7 +418,7 @@ private StorageRequest deleteImpl(
public HttpURLConnection buildRequest(
CloudFileClient client, CloudFileShare share, OperationContext context) throws Exception {
return FileRequest.deleteShare(
- share.getTransformedAddress().getPrimaryUri(), options, context, accessCondition);
+ share.getTransformedAddress().getPrimaryUri(), options, context, accessCondition, share.snapshotID, deleteSnapshotsOption);
}
@Override
@@ -506,7 +508,7 @@ public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOption
* If a storage service error occurred.
*/
@DoesServiceRequest
- protected boolean deleteIfExists(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options,
+ public boolean deleteIfExists(DeleteShareSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options,
OperationContext opContext) throws StorageException {
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -588,7 +590,7 @@ public void setRequestLocationMode() {
public HttpURLConnection buildRequest(CloudFileClient client, CloudFileShare share, OperationContext context)
throws Exception {
return FileRequest.getShareProperties(share.getTransformedAddress().getUri(this.getCurrentLocation()),
- options, context, accessCondition);
+ options, context, accessCondition, share.snapshotID);
}
@Override
@@ -656,7 +658,7 @@ public FileSharePermissions downloadPermissions(AccessCondition accessCondition,
opContext = new OperationContext();
}
- //assertNoSnapshot();
+ assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -717,135 +719,135 @@ public FileSharePermissions postProcessResponse(HttpURLConnection connection,
return getRequest;
}
-// /**
-// * Creates a snapshot of the share.
-// *
-// * @return A CloudFileShare
object that represents the snapshot of the share.
-// *
-// * @throws StorageException
-// * If a storage service error occurred.
-// */
-// @DoesServiceRequest
-// protected final CloudFileShare createSnapshot() throws StorageException {
-// return this
-// .createSnapshot(null /* metadata */, null /* accessCondition */, null /* options */, null /* opContext */);
-// }
-//
-// /**
-// * Creates a snapshot of the file share using the specified request options and operation context.
-// *
-// * @param accessCondition
-// * An {@link AccessCondition} object that represents the access conditions for the share.
-// * @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 (
-// * {@link CloudFileClient}).
-// * @param opContext
-// * An {@link OperationContext} object that represents the context for the current operation. This object
-// * is used to track requests to the storage service, and to provide additional runtime information about
-// * the operation.
-// *
-// * @return A CloudFileShare
object that represents the snapshot of the file share.
-// *
-// * @throws StorageException
-// * If a storage service error occurred.
-// */
-// @DoesServiceRequest
-// protected final CloudFileShare createSnapshot(final AccessCondition accessCondition, FileRequestOptions options,
-// OperationContext opContext) throws StorageException {
-// return this.createSnapshot(null /* metadata */, accessCondition, options, opContext);
-// }
-//
-// /**
-// * Creates a snapshot of the file share using the specified request options and operation context.
-// *
-// * @param metadata
-// * A collection of name-value pairs defining the metadata of the snapshot, or null.
-// * @param accessCondition
-// * An {@link AccessCondition} object that represents the access conditions for the file share.
-// * @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 (
-// * {@link CloudFileClient}).
-// * @param opContext
-// * An {@link OperationContext} object that represents the context for the current operation. This object
-// * is used to track requests to the storage service, and to provide additional runtime information about
-// * the operation.
-// *
-// * @return A CloudFileShare
object that represents the snapshot of the file share.
-// *
-// * @throws StorageException
-// * If a storage service error occurred.
-// */
-// @DoesServiceRequest
-// protected final CloudFileShare createSnapshot(final HashMap metadata,
-// final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
-// throws StorageException {
-// //assertNoSnapshot();
-//
-// if (opContext == null) {
-// opContext = new OperationContext();
-// }
-//
-// opContext.initialize();
-// options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
-//
-// return ExecutionEngine
-// .executeWithRetry(this.fileServiceClient, this,
-// this.createSnapshotImpl(metadata, accessCondition, options), options.getRetryPolicyFactory(),
-// opContext);
-// }
-
-// private StorageRequest createSnapshotImpl(
-// final HashMap metadata, final AccessCondition accessCondition,
-// final FileRequestOptions options) {
-// final StorageRequest putRequest =
-// new StorageRequest(
-// options, this.getStorageUri()) {
-//
-// @Override
-// public HttpURLConnection buildRequest(CloudFileClient client, CloudFileShare share, OperationContext context)
-// throws Exception {
-// return FileRequest.snapshotShare(share.getTransformedAddress().getUri(this.getCurrentLocation()),
-// options, context, accessCondition);
-// }
-//
-// @Override
-// public void setHeaders(HttpURLConnection connection, CloudFileShare share, OperationContext context) {
-// if (metadata != null) {
-// FileRequest.addMetadata(connection, metadata, context);
-// }
-// }
-//
-// @Override
-// public void signRequest(HttpURLConnection connection, CloudFileClient client, OperationContext context)
-// throws Exception {
-// StorageRequest.signBlobQueueAndFileRequest(connection, client, 0L, context);
-// }
-//
-// @Override
-// public CloudFileShare preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context)
-// throws Exception {
-// if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) {
-// this.setNonExceptionedRetryableFailure(true);
-// return null;
-// }
-//
-// final String snapshotTime = FileResponse.getSnapshotTime(this.getConnection());
-// CloudFileShare snapshot = new CloudFileShare(share.getName(), snapshotTime, client);
-// snapshot.setProperties(new FileShareProperties(share.properties));
-//
-// // use the specified metadata if not null : otherwise share's metadata
-// snapshot.setMetadata(metadata != null ? metadata : share.metadata);
-//
-// snapshot.updatePropertiesFromResponse(this.getConnection());
-//
-// return snapshot;
-// }
-// };
-//
-// return putRequest;
-// }
+ /**
+ * Creates a snapshot of the share.
+ *
+ * @return A CloudFileShare
object that represents the snapshot of the share.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ */
+ @DoesServiceRequest
+ public final CloudFileShare createSnapshot() throws StorageException {
+ return this
+ .createSnapshot(null /* metadata */, null /* accessCondition */, null /* options */, null /* opContext */);
+ }
+
+ /**
+ * Creates a snapshot of the file share using the specified request options and operation context.
+ *
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the share.
+ * @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 (
+ * {@link CloudFileClient}).
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ *
+ * @return A CloudFileShare
object that represents the snapshot of the file share.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ */
+ @DoesServiceRequest
+ public final CloudFileShare createSnapshot(final AccessCondition accessCondition, FileRequestOptions options,
+ OperationContext opContext) throws StorageException {
+ return this.createSnapshot(null /* metadata */, accessCondition, options, opContext);
+ }
+
+ /**
+ * Creates a snapshot of the file share using the specified request options and operation context.
+ *
+ * @param metadata
+ * A collection of name-value pairs defining the metadata of the snapshot, or null.
+ * @param accessCondition
+ * An {@link AccessCondition} object that represents the access conditions for the file share.
+ * @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 (
+ * {@link CloudFileClient}).
+ * @param opContext
+ * An {@link OperationContext} object that represents the context for the current operation. This object
+ * is used to track requests to the storage service, and to provide additional runtime information about
+ * the operation.
+ *
+ * @return A CloudFileShare
object that represents the snapshot of the file share.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ */
+ @DoesServiceRequest
+ public final CloudFileShare createSnapshot(final HashMap metadata,
+ final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
+ throws StorageException {
+ assertNoSnapshot();
+
+ if (opContext == null) {
+ opContext = new OperationContext();
+ }
+
+ opContext.initialize();
+ options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
+
+ return ExecutionEngine
+ .executeWithRetry(this.fileServiceClient, this,
+ this.createSnapshotImpl(metadata, accessCondition, options), options.getRetryPolicyFactory(),
+ opContext);
+ }
+
+ private StorageRequest createSnapshotImpl(
+ final HashMap metadata, final AccessCondition accessCondition,
+ final FileRequestOptions options) {
+ final StorageRequest putRequest =
+ new StorageRequest(
+ options, this.getStorageUri()) {
+
+ @Override
+ public HttpURLConnection buildRequest(CloudFileClient client, CloudFileShare share, OperationContext context)
+ throws Exception {
+ return FileRequest.snapshotShare(share.getTransformedAddress().getUri(this.getCurrentLocation()),
+ options, context, accessCondition);
+ }
+
+ @Override
+ public void setHeaders(HttpURLConnection connection, CloudFileShare share, OperationContext context) {
+ if (metadata != null) {
+ FileRequest.addMetadata(connection, metadata, context);
+ }
+ }
+
+ @Override
+ public void signRequest(HttpURLConnection connection, CloudFileClient client, OperationContext context)
+ throws Exception {
+ StorageRequest.signBlobQueueAndFileRequest(connection, client, 0L, context);
+ }
+
+ @Override
+ public CloudFileShare preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context)
+ throws Exception {
+ if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) {
+ this.setNonExceptionedRetryableFailure(true);
+ return null;
+ }
+
+ final String snapshotTime = FileResponse.getSnapshotTime(this.getConnection());
+ CloudFileShare snapshot = new CloudFileShare(share.getName(), snapshotTime, client);
+ snapshot.setProperties(new FileShareProperties(share.properties));
+
+ // use the specified metadata if not null : otherwise share's metadata
+ snapshot.setMetadata(metadata != null ? metadata : share.metadata);
+
+ snapshot.updatePropertiesFromResponse(this.getConnection());
+
+ return snapshot;
+ }
+ };
+
+ return putRequest;
+ }
/**
* Queries the service for this share's {@link ShareStats}.
@@ -883,7 +885,7 @@ public ShareStats getStats(FileRequestOptions options, OperationContext opContex
opContext = new OperationContext();
}
- //assertNoSnapshot();
+ assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
@@ -1004,7 +1006,7 @@ public void setRequestLocationMode() {
public HttpURLConnection buildRequest(CloudFileClient client, CloudFileShare share, OperationContext context)
throws Exception {
return FileRequest.getShareProperties(share.getTransformedAddress().getUri(this.getCurrentLocation()),
- options, context, accessCondition);
+ options, context, accessCondition, share.snapshotID);
}
@Override
@@ -1018,10 +1020,10 @@ public Boolean preProcessResponse(CloudFileShare share, CloudFileClient client,
throws Exception {
if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) {
share.updatePropertiesFromResponse(this.getConnection());
-// final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(),
-// client.isUsePathStyleUris());
-// share.metadata = attributes.getMetadata();
-// share.properties = attributes.getProperties();
+ final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(),
+ client.isUsePathStyleUris());
+ share.metadata = attributes.getMetadata();
+ share.properties = attributes.getProperties();
return Boolean.valueOf(true);
}
@@ -1057,14 +1059,14 @@ private void updatePropertiesFromResponse(HttpURLConnection request) {
}
}
-// /**
-// * Asserts that the share is not a snapshot.
-// */
-// protected void assertNoSnapshot() {
-// if (isSnapshot()) {
-// throw new IllegalArgumentException(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT);
-// }
-// }
+ /**
+ * Asserts that the share is not a snapshot.
+ */
+ protected void assertNoSnapshot() {
+ if (isSnapshot()) {
+ throw new IllegalArgumentException(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT);
+ }
+ }
/**
* Returns a shared access signature for the share. Note this does not contain the leading "?".
@@ -1173,7 +1175,7 @@ public void uploadMetadata() throws StorageException {
@DoesServiceRequest
public void uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
throws StorageException {
- //assertNoSnapshot();
+ assertNoSnapshot();
if (opContext == null) {
opContext = new OperationContext();
@@ -1263,7 +1265,7 @@ public final void uploadProperties() throws StorageException {
public final void uploadProperties(
AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
throws StorageException {
- //assertNoSnapshot();
+ assertNoSnapshot();
if (this.properties != null && this.properties.getShareQuota() != null) {
Utility.assertInBounds("Share Quota", this.properties.getShareQuota(), 1, FileConstants.MAX_SHARE_QUOTA);
@@ -1350,7 +1352,7 @@ public void uploadPermissions(final FileSharePermissions permissions) throws Sto
@DoesServiceRequest
public void uploadPermissions(final FileSharePermissions permissions, final AccessCondition accessCondition,
FileRequestOptions options, OperationContext opContext) throws StorageException {
- //assertNoSnapshot();
+ assertNoSnapshot();
if (opContext == null) {
opContext = new OperationContext();
@@ -1452,12 +1454,12 @@ private void parseQueryAndVerify(final StorageUri completeUri, final StorageCred
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri);
-// final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
+ final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
-// final String[] snapshotIDs = queryParameters.get(Constants.QueryConstants.SHARE_SNAPSHOT);
-// if (snapshotIDs != null && snapshotIDs.length > 0) {
-// this.snapshotID = snapshotIDs[0];
-// }
+ final String[] snapshotIDs = queryParameters.get(Constants.QueryConstants.SHARE_SNAPSHOT);
+ if (snapshotIDs != null && snapshotIDs.length > 0) {
+ this.snapshotID = snapshotIDs[0];
+ }
final StorageCredentialsSharedAccessSignature parsedCredentials =
SharedAccessSignatureHelper.parseQuery(completeUri);
@@ -1495,25 +1497,25 @@ public URI getUri() {
return this.storageUri.getPrimaryUri();
}
-// /**
-// * Returns the snapshotID for this share.
-// *
-// * @return The snapshotID as a string for this share.
-// */
-// protected final String getSnapshot() {
-// return this.snapshotID;
-// }
-//
-// /**
-// * Indicates whether this share is a snapshot.
-// *
-// * @return true
if the share is a snapshot, otherwise false
.
-// *
-// * @see DeleteSnapshotsOption
-// */
-// protected final boolean isSnapshot() {
-// return this.snapshotID != null;
-// }
+ /**
+ * Returns the snapshotID for this share.
+ *
+ * @return The snapshotID as a string for this share.
+ */
+ public final String getSnapshot() {
+ return this.snapshotID;
+ }
+
+ /**
+ * Indicates whether this share is a snapshot.
+ *
+ * @return true
if the share is a snapshot, otherwise false
.
+ *
+ * @see DeleteSnapshotsOption
+ */
+ public final boolean isSnapshot() {
+ return this.snapshotID != null;
+ }
/**
* Returns the list of URIs for all locations.
@@ -1524,23 +1526,23 @@ public StorageUri getStorageUri() {
return this.storageUri;
}
-// /**
-// * Returns the snapshot or shared access signature qualified URI for this share.
-// *
-// * @return A java.net.URI
object that represents the snapshot or shared access signature.
-// *
-// * @throws StorageException
-// * If a storage service error occurred.
-// * @throws URISyntaxException
-// * If the resource URI is invalid.
-// */
-// public final URI getQualifiedUri() throws URISyntaxException, StorageException {
-// if (this.isSnapshot()) {
-// return PathUtility.addToQuery(this.getUri(), String.format("sharesnapshot=%s", this.snapshotID));
-// }
-//
-// return this.fileServiceClient.getCredentials().transformUri(this.getUri());
-// }
+ /**
+ * Returns the snapshot or shared access signature qualified URI for this share.
+ *
+ * @return A java.net.URI
object that represents the snapshot or shared access signature.
+ *
+ * @throws StorageException
+ * If a storage service error occurred.
+ * @throws URISyntaxException
+ * If the resource URI is invalid.
+ */
+ public final URI getQualifiedUri() throws URISyntaxException, StorageException {
+ if (this.isSnapshot()) {
+ return PathUtility.addToQuery(this.getUri(), String.format("sharesnapshot=%s", this.snapshotID));
+ }
+
+ return this.fileServiceClient.getCredentials().transformUri(this.getUri());
+ }
/**
* Returns the name of the share.
@@ -1589,7 +1591,7 @@ public void setMetadata(final HashMap metadata) {
* A {@link FileShareProperties} object that represents the properties being assigned to the
* share.
*/
- protected void setProperties(final FileShareProperties properties) {
+ public void setProperties(final FileShareProperties properties) {
this.properties = properties;
}
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 fc29553cf84c7..49c5f33c439c7 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
@@ -131,7 +131,7 @@ private static void addProperties(final HttpURLConnection request, FilePropertie
* the share snapshot version to the query builder.
* @throws StorageException
*/
- protected static void addShareSnapshot(final UriQueryBuilder builder, final String snapshotVersion)
+ public static void addShareSnapshot(final UriQueryBuilder builder, final String snapshotVersion)
throws StorageException {
if (snapshotVersion != null) {
builder.add(Constants.QueryConstants.SHARE_SNAPSHOT, snapshotVersion);
@@ -288,26 +288,26 @@ public static HttpURLConnection deleteFile(final URI uri, final FileRequestOptio
* @throws IllegalArgumentException
*/
public static HttpURLConnection deleteShare(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, final AccessCondition accessCondition)
+ final OperationContext opContext, final AccessCondition accessCondition, String snapshotVersion, DeleteShareSnapshotsOption deleteSnapshotsOption)
throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
- //FileRequest.addShareSnapshot(shareBuilder, snapshotVersion);
+ FileRequest.addShareSnapshot(shareBuilder, snapshotVersion);
HttpURLConnection request = BaseRequest.delete(uri, fileOptions, shareBuilder, opContext);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
-// switch (deleteSnapshotsOption) {
-// case NONE:
-// // nop
-// break;
-// case INCLUDE_SNAPSHOTS:
-// request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
-// Constants.HeaderConstants.INCLUDE_SNAPSHOTS_VALUE);
-// break;
-// default:
-// break;
-// }
+ switch (deleteSnapshotsOption) {
+ case NONE:
+ // nop
+ break;
+ case INCLUDE_SNAPSHOTS:
+ request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
+ Constants.HeaderConstants.INCLUDE_SNAPSHOTS_VALUE);
+ break;
+ default:
+ break;
+ }
return request;
}
@@ -362,6 +362,8 @@ public static HttpURLConnection getAcl(final URI uri, final FileRequestOptions f
* the operation.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the file.
+ * @param snapshotVersion
+ * The snapshot version, if the share is a snapshot.
* @param offset
* The offset at which to begin returning content.
* @param count
@@ -378,7 +380,7 @@ public static HttpURLConnection getAcl(final URI uri, final FileRequestOptions f
* @throws IllegalArgumentException
*/
public static HttpURLConnection getFile(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, final AccessCondition accessCondition, final Long offset,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion, final Long offset,
final Long count, boolean requestRangeContentMD5) throws IOException, URISyntaxException, StorageException {
if (offset != null && requestRangeContentMD5) {
@@ -387,7 +389,7 @@ public static HttpURLConnection getFile(final URI uri, final FileRequestOptions
}
final UriQueryBuilder builder = new UriQueryBuilder();
- //FileRequest.addShareSnapshot(builder, snapshotVersion);
+ FileRequest.addShareSnapshot(builder, snapshotVersion);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
@@ -432,6 +434,8 @@ public static HttpURLConnection getFile(final URI uri, final FileRequestOptions
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the file.
* @return a HttpURLConnection to use to perform the operation.
+ * @param snapshotVersion
+ * the snapshot version to the query builder.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
@@ -441,11 +445,11 @@ public static HttpURLConnection getFile(final URI uri, final FileRequestOptions
* @throws IllegalArgumentException
*/
public static HttpURLConnection getFileProperties(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, final AccessCondition accessCondition) throws StorageException,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion) throws StorageException,
IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
- return getProperties(uri, fileOptions, opContext, accessCondition, builder);
+ return getProperties(uri, fileOptions, opContext, accessCondition, builder, snapshotVersion);
}
/**
@@ -475,11 +479,11 @@ public static HttpURLConnection getFileProperties(final URI uri, final FileReque
* @throws IllegalArgumentException
*/
public static HttpURLConnection getFileRanges(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, final AccessCondition accessCondition) throws StorageException,
+ final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion) throws StorageException,
IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
- //addShareSnapshot(builder, snapshotVersion);
+ addShareSnapshot(builder, snapshotVersion);
builder.add(Constants.QueryConstants.COMPONENT, RANGE_LIST_QUERY_ELEMENT_NAME);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
@@ -507,15 +511,17 @@ public static HttpURLConnection getFileRanges(final URI uri, final FileRequestOp
* the operation.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the share.
+ * @param snapshotVersion
+ * the snapshot version to the query builder.
* @return a HttpURLConnection configured for the operation.
* @throws StorageException
* */
public static HttpURLConnection getShareProperties(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, AccessCondition accessCondition) throws IOException, URISyntaxException,
+ final OperationContext opContext, AccessCondition accessCondition, final String snapshotVersion) throws IOException, URISyntaxException,
StorageException {
final UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
- return getProperties(uri, fileOptions, opContext, accessCondition, shareBuilder);
+ return getProperties(uri, fileOptions, opContext, accessCondition, shareBuilder, snapshotVersion);
}
/**
@@ -598,13 +604,16 @@ private static UriQueryBuilder getDirectoryUriQueryBuilder() throws StorageExcep
* the operation.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the share.
+ * @param snapshotVersion
+ * the snapshot version to the query builder.
* @return a HttpURLConnection configured for the operation.
* @throws StorageException
* */
private static HttpURLConnection getProperties(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, AccessCondition accessCondition, final UriQueryBuilder builder)
+ final OperationContext opContext, AccessCondition accessCondition, final UriQueryBuilder builder,
+ String snapshotVersion)
throws IOException, URISyntaxException, StorageException {
- //addShareSnapshot(builder, snapshotVersion);
+ addShareSnapshot(builder, snapshotVersion);
HttpURLConnection request = BaseRequest.getProperties(uri, fileOptions, builder, opContext);
if (accessCondition != null) {
@@ -631,7 +640,8 @@ private static HttpURLConnection getProperties(final URI uri, final FileRequestO
* @param listingContext
* A set of parameters for the listing operation.
* @param detailsIncluded
- * Additional details to return with the listing.
+ * A java.util.EnumSet
object that contains {@link ShareListingDetails} values that indicate
+ * whether share snapshots and/or metadata will be returned.
* @return a HttpURLConnection configured for the operation.
* @throws IOException
* @throws URISyntaxException
@@ -640,32 +650,28 @@ 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 ShareListingDetails detailsIncluded) throws URISyntaxException, IOException, StorageException {
+ final EnumSet 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.SNAPSHOTS)) {
+ started = true;
+ sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME);
+ }
-// if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
-// if (started)
-// {
-// sb.append(",");
-// }
-//
-// sb.append(Constants.QueryConstants.METADATA);
-// }
-
-// builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
-// }
-
- if (detailsIncluded == ShareListingDetails.ALL || detailsIncluded == ShareListingDetails.METADATA) {
- builder.add(Constants.QueryConstants.INCLUDE, Constants.QueryConstants.METADATA);
+ if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
+ if (started)
+ {
+ sb.append(",");
+ }
+
+ sb.append(Constants.QueryConstants.METADATA);
+ }
+
+ builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
}
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
@@ -801,14 +807,16 @@ public static HttpURLConnection deleteDirectory(final URI uri, final FileRequest
* the operation.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the directory.
+ * @param snapshotVersion
+ * the snapshot version to the query builder.
* @return a HttpURLConnection configured for the operation.
* @throws StorageException
* */
public static HttpURLConnection getDirectoryProperties(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, AccessCondition accessCondition) throws IOException, URISyntaxException,
+ final OperationContext opContext, AccessCondition accessCondition, String snapshotVersion) throws IOException, URISyntaxException,
StorageException {
final UriQueryBuilder directoryBuilder = getDirectoryUriQueryBuilder();
- return getProperties(uri, fileOptions, opContext, accessCondition, directoryBuilder);
+ return getProperties(uri, fileOptions, opContext, accessCondition, directoryBuilder, snapshotVersion);
}
/**
@@ -827,6 +835,8 @@ public static HttpURLConnection getDirectoryProperties(final URI uri, final File
* the operation.
* @param listingContext
* A set of parameters for the listing operation.
+ * @param snapshotVersion
+ * the snapshot version to the query builder.
* @return a HttpURLConnection configured for the operation.
* @throws IOException
* @throws URISyntaxException
@@ -834,11 +844,11 @@ public static HttpURLConnection getDirectoryProperties(final URI uri, final File
* @throws IllegalArgumentException
*/
public static HttpURLConnection listFilesAndDirectories(final URI uri, final FileRequestOptions fileOptions,
- final OperationContext opContext, final ListingContext listingContext) throws URISyntaxException,
+ final OperationContext opContext, final ListingContext listingContext, String snapshotVersion) throws URISyntaxException,
IOException, StorageException {
final UriQueryBuilder builder = getDirectoryUriQueryBuilder();
- //addShareSnapshot(builder, snapshotVersion);
+ addShareSnapshot(builder, snapshotVersion);
builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.LIST);
if (listingContext != null) {
diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListHandler.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListHandler.java
index 0721d15e7ccdd..3d3b9b99fd657 100644
--- a/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListHandler.java
+++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/file/ShareListHandler.java
@@ -107,7 +107,7 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
CloudFileShare retShare = this.serviceClient.getShareReference(this.shareName);
retShare.setMetadata(this.attributes.getMetadata());
retShare.setProperties(this.attributes.getProperties());
- //retShare.snapshotID = this.snapshotID;
+ retShare.snapshotID = this.snapshotID;
this.response.getResults().add(retShare);
}
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 87640da8982eb..14bb2c0753ec6 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
@@ -24,20 +24,15 @@ public enum ShareListingDetails {
*/
NONE(0),
- /**
- * Specifies including all available details.
- */
- ALL(1),
-
/**
* Specifies including share metadata.
*/
- METADATA(1);
+ METADATA(1),
/**
* Specifies listing share snapshots.
*/
- //SNAPSHOTS(2);
+ SNAPSHOTS(2);
/**
* Returns the value of this enum.
diff --git a/pom.xml b/pom.xml
index 9d5c3231d80fb..8aa563d667a22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
4.0.0
com.microsoft.azure
azure-storage
- 5.5.0
+ 6.0.0
jar
Microsoft Azure Storage Client SDK