CloudFileDirectory Class
- java.
lang. Object - ListFileItem
- com.
microsoft. azure. storage. file. CloudFileDirectory
- com.
public class CloudFileDirectory implements ListFileItem
Represents a virtual directory of files.
Directories, which are encapsulated as CloudFileDirectory objects, hold files and can also contain sub-directories.
Constructor Summary
Constructor | Description |
---|---|
CloudFileDirectory(final StorageUri directoryAbsoluteUri) |
Creates an instance of the class using an absolute URI to the directory. |
CloudFileDirectory(final StorageUri directoryAbsoluteUri, final StorageCredentials credentials) |
Creates an instance of the class using an absolute URI to the directory and credentials. |
CloudFileDirectory(final StorageUri uri, final String directoryName, final CloudFileShare share) |
Creates an instance of the class using the specified address, share, and client. |
CloudFileDirectory(final URI directoryAbsoluteUri) |
Creates an instance of the class using an absolute URI to the directory. |
CloudFileDirectory(final URI directoryAbsoluteUri, final StorageCredentials credentials) |
Creates an instance of the class using an absolute URI to the directory and credentials. |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
assertValidFilePermissionOrKey()
Verifies that the directory's filePermission and properties.filePermissionKey are both not set. |
Result |
closeAllHandlesSegmented()
Close all SMB handles on this file. |
Result |
closeAllHandlesSegmented(final ResultContinuation continuationToken, boolean recursive, FileRequestOptions options, OperationContext opContext)
Close all SMB handles on this file. |
Result |
closeHandleSegmented(String handleID)
Close all SMB handles on this file. |
Result |
closeHandleSegmented(String handleID, ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Close all SMB handles on this file. |
void |
create()
Creates the directory. |
void |
create(FileRequestOptions options, OperationContext opContext)
Creates the directory using the specified options and operation context. |
boolean |
createIfNotExists()
Creates the directory if it does not exist. |
boolean |
createIfNotExists(FileRequestOptions options, OperationContext opContext)
Creates the directory if it does not exist, using the specified request options and operation context. |
void |
delete()
Deletes the directory. |
void |
delete(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the directory using the specified request options and operation context. |
boolean |
deleteIfExists()
Deletes the directory if it exists. |
boolean |
deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the directory if it exists using the specified request options and operation context. |
void |
downloadAttributes()
Downloads the directory's properties. |
void |
downloadAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads the directory's properties using the specified request options and operation context. |
boolean |
exists()
Returns a value that indicates whether the directory exists. |
boolean |
exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Returns a value that indicates whether the directory exists, using the specified request options and operation context. |
Cloud |
getDirectoryReference(final String itemName)
Returns a reference to a CloudFileDirectory object that represents a directory in this directory. |
Cloud |
getFileReference(final String fileName)
Returns a reference to a CloudFile object that represents a file in this directory. |
HashMap<String, String> |
getMetadata()
Returns the metadata for the directory. This value is initialized with the metadata from the directory by a call to downloadAttributes(), and is set on the directory with a call to uploadMetadata(). |
String |
getName()
Returns the name of this directory. |
Cloud |
getParent()
Returns the CloudFileDirectory parent directory associated with this directory. |
File |
getProperties()
Returns the FileDirectoryProperties object that holds the directory's system properties. |
Cloud |
getServiceClient()
Returns the File service client associated with this directory. |
Cloud |
getShare()
Returns the share for this directory. |
final Storage |
getStorageUri()
Returns the list of URIs for all locations. |
URI |
getUri()
Returns the URI for this directory. |
Iterable<List |
listFilesAndDirectories()
Returns an enumerable collection of file and directory items for the directory. |
Iterable<List |
listFilesAndDirectories(FileRequestOptions options, OperationContext opContext)
Returns an enumerable collection of file and directory items for the directory. |
Iterable<List |
listFilesAndDirectories(String prefix, FileRequestOptions options, OperationContext opContext)
Returns an enumerable collection of file and directory items for the directory. |
Result |
listFilesAndDirectoriesSegmented()
Returns a result segment of an enumerable collection of files and directories for this File service client. |
Result |
listFilesAndDirectoriesSegmented(final Integer maxResults, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Returns a result segment of an enumerable collection of files and directories for this directory, using the specified listing details options, request options, and operation context. |
Result |
listFilesAndDirectoriesSegmented(final String prefix, final Integer maxResults, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Returns a result segment of an enumerable collection of files and directories for this directory, using the specified listing details options, request options, and operation context. |
Iterable<File |
listHandles()
Gets the SMB handles open on this file. |
Iterable<File |
listHandles(boolean recursive, FileRequestOptions options, OperationContext opContext)
Gets the SMB handles open on this file. |
Result |
listHandlesSegmented()
Gets the SMB handles open on this file. |
Result |
listHandlesSegmented(final Integer maxResults, final boolean recursive, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Gets the SMB handles open on this file. |
void |
setFilePermission(String filePermission)
Sets the directory's file permission |
void |
setMetadata(HashMap<String, String> metadata)
Sets the metadata collection of name-value pairs to be set on the directory with an uploadMetadata() call. This collection will overwrite any existing directory metadata. If this is set to an empty collection, the directory metadata will be cleared on an uploadMetadata() call. |
final void |
setProperties(final FileDirectoryProperties properties)
Sets the properties for the directory. |
final void |
setShare(final CloudFileShare share)
Sets the share for the directory. |
void |
setStorageUri(final StorageUri storageUri)
Sets the list of URIs for all locations. |
void |
uploadMetadata()
Uploads the directory's metadata. |
void |
uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the directory's metadata using the specified request options and operation context. |
final void |
uploadProperties()
Uploads the directory's properties to the storage service. Use downloadAttributes() to retrieve the latest values for the directory's properties and metadata from the Microsoft Azure storage service. |
final void |
uploadProperties(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the directory's properties using the access condition, request options, and operation context. Use downloadAttributes() to retrieve the latest values for the directory's properties and metadata from the Microsoft Azure storage service. |
Constructor Details
CloudFileDirectory
public CloudFileDirectory(final StorageUri directoryAbsoluteUri)
Creates an instance of the class using an absolute URI to the directory.
Parameters:
Throws:
CloudFileDirectory
public CloudFileDirectory(final StorageUri directoryAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using an absolute URI to the directory and credentials.
Parameters:
Throws:
CloudFileDirectory
protected CloudFileDirectory(final StorageUri uri, final String directoryName, final CloudFileShare share)
Creates an instance of the class using the specified address, share, and client.
Parameters:
String
that represents the name of the directory.
CloudFileDirectory
public CloudFileDirectory(final URI directoryAbsoluteUri)
Creates an instance of the class using an absolute URI to the directory.
Parameters:
Throws:
CloudFileDirectory
public CloudFileDirectory(final URI directoryAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using an absolute URI to the directory and credentials.
Parameters:
Throws:
Method Details
assertValidFilePermissionOrKey
protected void assertValidFilePermissionOrKey()
Verifies that the directory's filePermission and properties.filePermissionKey are both not set.
closeAllHandlesSegmented
public ResultSegment
Close all SMB handles on this file.
Returns:
Throws:
closeAllHandlesSegmented
public ResultSegment
Close all SMB handles on this file.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
closeHandleSegmented
public ResultSegment
Close all SMB handles on this file.
Parameters:
Returns:
Throws:
closeHandleSegmented
public ResultSegment
Close all SMB handles on this file.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
create
public void create()
Creates the directory.
Throws:
create
public void create(FileRequestOptions options, OperationContext opContext)
Creates the directory using the specified options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
createIfNotExists
public boolean createIfNotExists()
Creates the directory if it does not exist.
Returns:
true
if the directory did not already exist and was created; otherwise, false
.
Throws:
createIfNotExists
public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext)
Creates the directory if it does not exist, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client (CloudFileClient).
Returns:
true
if the directory did not already exist and was created; otherwise, false
.
Throws:
delete
public void delete()
Deletes the directory.
Throws:
delete
public void delete(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the directory using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
deleteIfExists
public boolean deleteIfExists()
Deletes the directory if it exists.
Returns:
true
if the directory did not already exist and was created; otherwise, false
.
Throws:
deleteIfExists
public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Deletes the directory if it exists using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the directory existed and was deleted; otherwise, false
.
Throws:
downloadAttributes
public void downloadAttributes()
Downloads the directory's properties.
Throws:
downloadAttributes
public void downloadAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads the directory's properties using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
exists
public boolean exists()
Returns a value that indicates whether the directory exists.
Returns:
true
if the directory exists, otherwise false
.
Throws:
exists
public boolean exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Returns a value that indicates whether the directory exists, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the directory exists, otherwise false
.
Throws:
getDirectoryReference
public CloudFileDirectory getDirectoryReference(final String itemName)
Returns a reference to a CloudFileDirectory object that represents a directory in this directory.
Parameters:
String
that represents the name of the directory.
Returns:
Throws:
getFileReference
public CloudFile getFileReference(final String fileName)
Returns a reference to a CloudFile object that represents a file in this directory.
Parameters:
String
that represents the name of the file.
Returns:
Throws:
getMetadata
public HashMap
Returns the metadata for the directory. This value is initialized with the metadata from the directory by a call to downloadAttributes(), and is set on the directory with a call to uploadMetadata().
Returns:
java.util.HashMap
object that represents the metadata for the directory.getName
public String getName()
Returns the name of this directory.
Returns:
String
that represents the name of the directory.getParent
public CloudFileDirectory getParent()
Returns the CloudFileDirectory parent directory associated with this directory.
Overrides:
CloudFileDirectory.getParent()Returns:
Throws:
getProperties
public FileDirectoryProperties getProperties()
Returns the FileDirectoryProperties object that holds the directory's system properties.
Returns:
getServiceClient
public CloudFileClient getServiceClient()
Returns the File service client associated with this directory.
Returns:
getShare
public CloudFileShare getShare()
Returns the share for this directory.
Overrides:
CloudFileDirectory.getShare()Returns:
Throws:
getStorageUri
public final StorageUri getStorageUri()
Returns the list of URIs for all locations.
Overrides:
CloudFileDirectory.getStorageUri()Returns:
getUri
public URI getUri()
Returns the URI for this directory.
Overrides:
CloudFileDirectory.getUri()Returns:
java.net.URI
object that represents the URI for this directory.listFilesAndDirectories
public Iterable
Returns an enumerable collection of file and directory items for the directory.
Returns:
listFilesAndDirectories
public Iterable
Returns an enumerable collection of file and directory items for the directory.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
listFilesAndDirectories
public Iterable
Returns an enumerable collection of file and directory items for the directory.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
listFilesAndDirectoriesSegmented
public ResultSegment
Returns a result segment of an enumerable collection of files and directories for this File service client.
Returns:
Throws:
listFilesAndDirectoriesSegmented
public ResultSegment
Returns a result segment of an enumerable collection of files and directories for this directory, using the specified listing details options, request options, and operation context.
Parameters:
null
or greater than 5000, the server will return up to 5,000 items. Must be at least 1.
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
listFilesAndDirectoriesSegmented
public ResultSegment
Returns a result segment of an enumerable collection of files and directories for this directory, using the specified listing details options, request options, and operation context.
Parameters:
null
or greater than 5000, the server will return up to 5,000 items. Must be at least 1.
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
listHandles
public Iterable
Gets the SMB handles open on this file.
Returns:
AnIterable
</code> of the handles that will lazily request new segments. </p>
listHandles
public Iterable listHandles(boolean recursive, FileRequestOptions options, OperationContext opContext)
Gets the SMB handles open on this file.
Parameters:
recursive
- Specifies if operation should apply to the directory specified in the URI, its files, its subdirectories and their files.
options
- A FileRequestOptions object that specifies any additional options for the request. Specifying null
will use the default request options from the associated service client ( CloudFileClient).
opContext
- An OperationContext object which 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.
Returns:
AnIterable
</code> of the handles that will lazily request new segments. </p>
listHandlesSegmented
public ResultSegment listHandlesSegmented()
Gets the SMB handles open on this file.
Returns:
A ResultSegment<T> object that contains a segment of the enumerable collection of ListFileItem objects that represent the files and directories.
Throws:
StorageException
listHandlesSegmented
public ResultSegment listHandlesSegmented(final Integer maxResults, final boolean recursive, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Gets the SMB handles open on this file.
Parameters:
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.
recursive
- Specifies if operation should apply to the directory specified in the URI, its files, its subdirectories and their files.
continuationToken
- A ResultContinuation object that represents a continuation token returned by a previous listing operation.
options
- A FileRequestOptions object that specifies any additional options for the request. Specifying null
will use the default request options from the associated service client ( CloudFileClient).
opContext
- An OperationContext object which 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.
Returns:
A ResultSegment<T> object that contains a segment of the enumerable collection of ListFileItem objects that represent the files and directories.
Throws:
StorageException
setFilePermission
public void setFilePermission(String filePermission)
Sets the directory's file permission
Parameters:
filePermission
- A String
that represents the directory's file permission.
setMetadata
public void setMetadata(HashMap metadata)
Sets the metadata collection of name-value pairs to be set on the directory with an uploadMetadata() call. This collection will overwrite any existing directory metadata. If this is set to an empty collection, the directory metadata will be cleared on an uploadMetadata() call.
Parameters:
metadata
- A java.util.HashMap
object that represents the metadata being assigned to the directory.
setProperties
protected final void setProperties(final FileDirectoryProperties properties)
Sets the properties for the directory.
Parameters:
properties
- A FileDirectoryProperties object that represents the properties being assigned to the directory.
setShare
protected final void setShare(final CloudFileShare share)
Sets the share for the directory.
Parameters:
share
- A CloudFileShare object that represents the share being assigned to the directory.
setStorageUri
protected void setStorageUri(final StorageUri storageUri)
Sets the list of URIs for all locations.
Parameters:
storageUri
- A StorageUri that represents the list of URIs for all locations.
uploadMetadata
public void uploadMetadata()
Uploads the directory's metadata.
Throws:
StorageException
- If a storage service error occurred.
URISyntaxException
uploadMetadata
public void uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the directory's metadata using the specified request options and operation context.
Parameters:
accessCondition
- An AccessCondition object that represents the access conditions for the directory.
options
- A FileRequestOptions object that specifies any additional options for the request. Specifying null
will use the default request options from the associated service client ( CloudFileClient).
opContext
- An 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.
Throws:
StorageException
- If a storage service error occurred.
URISyntaxException
uploadProperties
public final void uploadProperties()
Uploads the directory's properties to the storage service.
Use downloadAttributes() to retrieve the latest values for the directory's properties and metadata from the Microsoft Azure storage service.
Throws:
StorageException
- If a storage service error occurred.
URISyntaxException
uploadProperties
public final void uploadProperties(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Uploads the directory's properties using the access condition, request options, and operation context.
Use downloadAttributes() to retrieve the latest values for the directory's properties and metadata from the Microsoft Azure storage service.
Parameters:
accessCondition
- An AccessCondition object that represents the access conditions for the directory.
options
- A FileRequestOptions object that specifies any additional options for the request. Specifying null
will use the default request options from the associated service client ( CloudFileClient).
opContext
- An 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.
Throws:
StorageException
- If a storage service error occurred.
URISyntaxException
Applies to
Azure SDK for Java