/** * Appends a path to a list of URIs correctly using "/" as separator. * * @param uriList * The base Uri. * @param relativeOrAbslouteUri * The relative or absloute URI. * @return The appended Uri. * @throws URISyntaxException */ public static StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri) throws URISyntaxException { return appendPathToUri(uriList, relativeOrAbsoluteUri, "/"); }
/** * Appends a path to a list of URIs correctly using "/" as separator. * * @param uriList * The base Uri. * @param relativeOrAbsoluteUri * The relative or absolute URI. * @return The appended Uri. * @throws URISyntaxException */ public static StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri) throws URISyntaxException { return appendPathToUri(uriList, relativeOrAbsoluteUri, "/"); }
/** * Get a single message request (Used internally only). * * @return The <code>URI</code> for a single message request. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ private StorageUri getIndividualMessageAddress(final String messageId, final OperationContext opContext) throws URISyntaxException, StorageException { return PathUtility.appendPathToUri(this.getMessageRequestAddress(opContext), messageId); }
/** * Get a single message request (Used internally only). * * @return The <code>URI</code> for a single message request. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ private StorageUri getIndividualMessageAddress(final String messageId, final OperationContext opContext) throws URISyntaxException, StorageException { return PathUtility.appendPathToUri(this.getMessageRequestAddress(opContext), messageId); }
/** * Get the message request base address (Used internally only). * * @return The message request <code>URI</code>. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ private StorageUri getMessageRequestAddress(final OperationContext opContext) throws URISyntaxException, StorageException { if (this.messageRequestAddress == null) { this.messageRequestAddress = PathUtility.appendPathToUri(this.getTransformedAddress(opContext), QueueConstants.MESSAGES); } return this.messageRequestAddress; }
/** * Get the message request base address (Used internally only). * * @return The message request <code>URI</code>. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ private StorageUri getMessageRequestAddress(final OperationContext opContext) throws URISyntaxException, StorageException { if (this.messageRequestAddress == null) { this.messageRequestAddress = PathUtility.appendPathToUri(this.getTransformedAddress(opContext), QueueConstants.MESSAGES); } return this.messageRequestAddress; }
/** * Returns a reference to a {@link CloudBlobDirectory} object that represents a virtual blob directory within this * container. * * @param directoryName * A <code>String</code> that represents the name of the virtual blob directory. If the root directory * (the directory representing the container itself) is desired, use an empty string. * @return A {@link CloudBlobDirectory} that represents a virtual blob directory within this container. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudBlobDirectory getDirectoryReference(String directoryName) throws URISyntaxException { Utility.assertNotNull("directoryName", directoryName); // if the directory name does not end in the delimiter, add the delimiter if (!directoryName.isEmpty() && !directoryName.endsWith(this.blobServiceClient.getDirectoryDelimiter())) { directoryName = directoryName.concat(this.blobServiceClient.getDirectoryDelimiter()); } final StorageUri address = PathUtility.appendPathToUri(this.storageUri, directoryName); return new CloudBlobDirectory(address, directoryName, this.blobServiceClient, this); }
/** * Returns a reference to a {@link CloudBlobDirectory} object that represents a virtual blob directory within this * container. * * @param directoryName * A <code>String</code> that represents the name of the virtual blob directory. If the root directory * (the directory representing the container itself) is desired, use an empty string. * @return A {@link CloudBlobDirectory} that represents a virtual blob directory within this container. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudBlobDirectory getDirectoryReference(String directoryName) throws URISyntaxException { Utility.assertNotNull("directoryName", directoryName); // if the directory name does not end in the delimiter, add the delimiter if (!directoryName.isEmpty() && !directoryName.endsWith(this.blobServiceClient.getDirectoryDelimiter())) { directoryName = directoryName.concat(this.blobServiceClient.getDirectoryDelimiter()); } final StorageUri address = PathUtility.appendPathToUri(this.storageUri, directoryName); return new CloudBlobDirectory(address, directoryName, this.blobServiceClient, this); }
/** * Gets the container URI from a blob address * * @param blobAddress * the blob address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the container URI from a blob address * @throws URISyntaxException */ public static StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris) throws URISyntaxException { final String containerName = getContainerNameFromUri(blobAddress.getPrimaryUri(), usePathStyleUris); final StorageUri containerUri = appendPathToUri(getServiceClientBaseAddress(blobAddress, usePathStyleUris), containerName); return containerUri; }
/** * Gets the share URI from a file address * * @param fileAddress * the file address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the share URI from a file address * @throws URISyntaxException */ public static StorageUri getShareURI(final StorageUri fileAddress, final boolean usePathStyleUris) throws URISyntaxException { final String shareName = getShareNameFromUri(fileAddress.getPrimaryUri(), usePathStyleUris); final StorageUri shareUri = appendPathToUri(getServiceClientBaseAddress(fileAddress, usePathStyleUris), shareName); return shareUri; }
/** * Returns a reference to a {@link CloudFileDirectory} object that represents a directory in this directory. * * @param itemName * A <code>String</code> that represents the name of the directory. * * @return A {@link CloudFileDirectory} object that represents a reference to the specified directory. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ public CloudFileDirectory getDirectoryReference(final String itemName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("itemName", itemName); StorageUri subdirectoryUri = PathUtility.appendPathToUri(this.storageUri, itemName); return new CloudFileDirectory(subdirectoryUri, itemName, this.getShare()); }
/** * Returns a reference to a {@link CloudFile} object that represents a file in this directory. * * @param fileName * A <code>String</code> that represents the name of the file. * * @return A {@link CloudFile} object that represents a reference to the specified file. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudFile getFileReference(final String fileName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("fileName", fileName); StorageUri subdirectoryUri = PathUtility.appendPathToUri(this.storageUri, fileName); return new CloudFile(subdirectoryUri, fileName, this.getShare()); }
/** * Gets the container URI from a blob address * * @param blobAddress * the blob address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the container URI from a blob address * @throws URISyntaxException */ public static StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris) throws URISyntaxException { final String containerName = getContainerNameFromUri(blobAddress.getPrimaryUri(), usePathStyleUris); final StorageUri containerUri = appendPathToUri(getServiceClientBaseAddress(blobAddress, usePathStyleUris), containerName); return containerUri; }
/** * Returns a reference to a {@link CloudFile} object that represents a file in this directory. * * @param fileName * A <code>String</code> that represents the name of the file. * * @return A {@link CloudFile} object that represents a reference to the specified file. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudFile getFileReference(final String fileName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("fileName", fileName); StorageUri subdirectoryUri = PathUtility.appendPathToUri(this.storageUri, fileName); return new CloudFile(subdirectoryUri, fileName, this.getShare()); }
/** * Returns a reference to a {@link CloudFileDirectory} object that represents a directory in this directory. * * @param itemName * A <code>String</code> that represents the name of the directory. * * @return A {@link CloudFileDirectory} object that represents a reference to the specified directory. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ public CloudFileDirectory getDirectoryReference(final String itemName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("itemName", itemName); StorageUri subdirectoryUri = PathUtility.appendPathToUri(this.storageUri, itemName); return new CloudFileDirectory(subdirectoryUri, itemName, this.getShare()); }
/** * Gets the share URI from a file address * * @param fileAddress * the file address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the share URI from a file address * @throws URISyntaxException */ public static StorageUri getShareURI(final StorageUri fileAddress, final boolean usePathStyleUris) throws URISyntaxException { final String shareName = getShareNameFromUri(fileAddress.getPrimaryUri(), usePathStyleUris); final StorageUri shareUri = appendPathToUri(getServiceClientBaseAddress(fileAddress, usePathStyleUris), shareName); return shareUri; }
/** * Check if a directory reference with metadata will still have that metadata after being created. * * @throws StorageException * @throws URISyntaxException */ @Test public void testCreateDirectoryWithMetadata() throws StorageException, URISyntaxException { String directoryName = "newDirectory1"; CloudFileDirectory directory = new CloudFileDirectory( PathUtility.appendPathToUri(this.share.getStorageUri(), directoryName), directoryName, this.share); Assert.assertEquals(0, directory.getMetadata().size()); directory.getMetadata().put("key1", "value1"); directory.createIfNotExists(); directory.getMetadata().clear(); directory.downloadAttributes(); Assert.assertEquals(1, directory.getMetadata().size()); Assert.assertEquals("value1", directory.getMetadata().get("key1")); }
/** * Returns the file item's parent. * * @return A {@link CloudFileDirectory} object that represents the parent directory for the file. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Override public final CloudFileDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { final String parentName = getParentNameFromURI(this.getStorageUri(), this.getShare()); if (parentName != null) { StorageUri parentURI = PathUtility.appendPathToUri(this.share.getStorageUri(), parentName); this.parent = new CloudFileDirectory(parentURI, this.getServiceClient().getCredentials()); } } return this.parent; }
/** * Returns the blob item's parent. * * @return A {@link CloudBlobDirectory} object that represents the parent directory for the blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Override public final CloudBlobDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { final String parentName = getParentNameFromURI(this.getStorageUri(), this.blobServiceClient.getDirectoryDelimiter(), this.getContainer()); if (parentName != null) { StorageUri parentURI = PathUtility.appendPathToUri(this.container.getStorageUri(), parentName); this.parent = new CloudBlobDirectory(parentURI, parentName, this.blobServiceClient, this.getContainer()); } } return this.parent; }
/** * Returns the {@link CloudFileDirectory} parent directory associated with this directory. * * @return An {@link CloudFileDirectory} object that represents the parent directory associated with the directory. * @throws StorageException * @throws URISyntaxException */ @Override public CloudFileDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { final String parentName = CloudFile.getParentNameFromURI(this.getStorageUri(), this.getShare()); if (parentName != null) { StorageUri parentURI = PathUtility.appendPathToUri(this.getShare().getStorageUri(), parentName); this.parent = new CloudFileDirectory(parentURI, this.getServiceClient().getCredentials()); } } return this.parent; }