/** * Returns the snapshot or shared access signature qualified URI for this share. * * @return A <code>java.net.URI</code> 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 <code>java.net.URI</code> 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()); }
/** * Tests directory creation with absolute uris. * * @throws URISyntaxException * @throws StorageException */ @Test @Category({ DevFabricTests.class, DevStoreTests.class, CloudTests.class }) public void testCloudFileDirectoryAbsoluteUriAppended() throws URISyntaxException, StorageException { CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference( this.share.getUri().toString()); assertEquals(PathUtility.appendPathToUri(this.share.getStorageUri(), this.share.getUri().toString()) .getPrimaryUri(), dir.getUri()); assertEquals(new URI(this.share.getUri() + "/" + this.share.getUri()), dir.getUri()); dir = this.share.getRootDirectoryReference().getDirectoryReference(this.share.getUri() + "/TopDir1"); assertEquals( PathUtility.appendPathToUri(this.share.getStorageUri(), this.share.getUri().toString() + "/TopDir1") .getPrimaryUri(), dir.getUri()); }
String shareSasHttp = this.share.generateSharedAccessSignature(policy, null, null, SharedAccessProtocols.HTTPS_HTTP); final URI httpUri = new URI("http", this.share.getUri().getAuthority(), this.share.getUri().getPath(), this.share.getUri().getQuery(), null); final URI httpsUri = new URI("https", this.share.getUri().getAuthority(), this.share.getUri().getPath(), this.share.getUri().getQuery(), null);
@Test public void testCloudStorageAccountClientUriVerify() throws URISyntaxException, StorageException { StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, true); CloudBlobClient blobClient = cloudStorageAccount.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); assertEquals(cloudStorageAccount.getBlobEndpoint().toString() + "/container1", container.getUri().toString()); CloudQueueClient queueClient = cloudStorageAccount.createCloudQueueClient(); CloudQueue queue = queueClient.getQueueReference("queue1"); assertEquals(cloudStorageAccount.getQueueEndpoint().toString() + "/queue1", queue.getUri().toString()); CloudTableClient tableClient = cloudStorageAccount.createCloudTableClient(); CloudTable table = tableClient.getTableReference("table1"); assertEquals(cloudStorageAccount.getTableEndpoint().toString() + "/table1", table.getUri().toString()); CloudFileClient fileClient = cloudStorageAccount.createCloudFileClient(); CloudFileShare share = fileClient.getShareReference("share1"); assertEquals(cloudStorageAccount.getFileEndpoint().toString() + "/share1", share.getUri().toString()); }
assertEquals(item11.getUri().toString(), this.share.getUri() + "/TopDir1/File1"); assertEquals("File1", ((CloudFile) item11).getName()); assertEquals(item12.getUri().toString(), this.share.getUri() + "/TopDir1/MidDir1"); assertEquals("MidDir1", ((CloudFileDirectory) item12).getName()); assertEquals(item13.getUri().toString(), this.share.getUri() + "/TopDir1/MidDir2"); assertEquals("MidDir2", ((CloudFileDirectory) item13).getName()); CloudFileDirectory midDir2 = (CloudFileDirectory) item13; assertEquals(item21.getUri().toString(), this.share.getUri() + "/TopDir1/MidDir2/EndDir1"); assertEquals("EndDir1", ((CloudFileDirectory) item21).getName()); assertEquals(item22.getUri().toString(), this.share.getUri() + "/TopDir1/MidDir2/EndDir2"); assertEquals("EndDir2", ((CloudFileDirectory) item22).getName());
assertEquals(this.share.getUri() + "/TopDir1/File1", item.getUri().toString()); assertEquals("File1", ((CloudFile) item).getName()); item = simpleList.get(0); ListFileItem item2 = simpleList.get(1); assertEquals(this.share.getUri() + "/TopDir1/MidDir1", item.getUri().toString()); assertEquals("MidDir1", ((CloudFileDirectory) item).getName()); assertEquals(this.share.getUri() + "/TopDir1/MidDir2", item2.getUri().toString()); assertEquals("MidDir2", ((CloudFileDirectory) item2).getName()); assertEquals(1, segmentResults.getResults().size()); item = segmentResults.getResults().get(0); assertEquals(this.share.getUri() + "/TopDir1/MidDir1", item.getUri().toString()); assertEquals("MidDir1", ((CloudFileDirectory)item).getName()); assertEquals(2, segmentResults.getResults().size()); item = segmentResults.getResults().get(0); assertEquals(this.share.getUri() + "/TopDir1/MidDir1", item.getUri().toString()); assertEquals("MidDir1", ((CloudFileDirectory)item).getName()); item = segmentResults.getResults().get(1); assertEquals(this.share.getUri() + "/TopDir1/MidDir2", item.getUri().toString()); assertEquals("MidDir2", ((CloudFileDirectory)item).getName());
CloudFileShare sasShare = new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), sasToken2));
/** * Tests directory hierarchy navigation. * * @throws URISyntaxException * @throws StorageException */ public void testCloudFileDirectoryFileParentValidate() throws URISyntaxException, StorageException { CloudFile file = this.share.getRootDirectoryReference().getDirectoryReference("TopDir1") .getDirectoryReference("MidDir1").getDirectoryReference("EndDir1").getFileReference("EndFile1"); CloudFileDirectory directory = file.getParent(); assertEquals(directory.getName(), "EndDir1"); assertEquals(directory.getUri().toString(), this.share.getUri() + "/TopDir1/MidDir1/EndDir1"); }
String shareSasNone = this.share.generateSharedAccessSignature(policy, null, range2, null); CloudFileShare noneShare = new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), shareSasNone)); new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), shareSasOne)); new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), shareSasAll));
new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), shareReadListSas));
CloudFileShare snapshotRef5 = new CloudFileShare(uriBuilder.addToURI(this.share.getUri()), this.share.getServiceClient().getCredentials()); assertEquals(snapshot.snapshotID, snapshotRef5.snapshotID);
URI sasUri = sasClient.getShareReference(share.getName()).getUri(); sasUri = sasClient.getCredentials().transformUri(sasUri); final CloudFileShare sasShare = new CloudFileShare(sasUri);
share = new CloudFileShare(credentials.transformUri(share.getUri())); file = share.getRootDirectoryReference().getFileReference(file.getName());
/** * Tests directory hierarchy navigation. * * @throws StorageException * @throws URISyntaxException */ @Test @Category({ DevFabricTests.class, DevStoreTests.class, CloudTests.class }) public void testCloudFileDirectoryGetParent() throws StorageException, URISyntaxException { CloudFile file = this.share.getRootDirectoryReference().getDirectoryReference("Dir1") .getFileReference("File1"); assertEquals("File1", file.getName()); // get the file's parent CloudFileDirectory parent = file.getParent(); assertEquals(parent.getName(), "Dir1"); // get share as parent CloudFileDirectory root = parent.getParent(); assertEquals(root.getName(), ""); // make sure the parent of the share dir is null CloudFileDirectory empty = root.getParent(); assertNull(empty); // from share, get directory reference to share root = this.share.getRootDirectoryReference(); assertEquals("", root.getName()); assertEquals(this.share.getUri(), root.getUri()); // make sure the parent of the share dir is null empty = root.getParent(); assertNull(empty); }