public class JCloudsFileSytem extends FileSystem
Modifier and Type | Class and Description |
---|---|
(package private) class |
JCloudsFileSytem.ListingIterator |
private class |
JCloudsFileSytem.RecursiveListIterator |
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.String |
adaptorName |
(package private) java.lang.String |
bucket |
(package private) org.jclouds.blobstore.BlobStoreContext |
context |
private static java.lang.String |
NOT_EMPTY |
(package private) boolean |
open |
Constructor and Description |
---|
JCloudsFileSytem(java.lang.String uniqueID,
java.lang.String adaptorName,
java.lang.String endPoint,
Credential credential,
Path workingDir,
org.jclouds.blobstore.BlobStoreContext context,
java.lang.String bucket,
int bufferSize,
XenonProperties properties) |
Modifier and Type | Method and Description |
---|---|
java.io.OutputStream |
appendToFile(Path file)
Open an existing file and return an
OutputStream to append data to this file. |
(package private) void |
checkClosed() |
void |
close()
Close this FileSystem.
|
void |
createDirectory(Path dir)
Creates a new directory, failing if the directory already exists.
|
void |
createFile(Path file)
Creates a new empty file, failing if the file already exists.
|
void |
createSymbolicLink(Path link,
Path target)
Creates a new symbolic link, failing if the link already exists (optional operation).
|
protected void |
deleteDirectory(Path dir)
Delete an empty directory.
|
void |
deleteFile(Path file)
Delete a file.
|
private boolean |
dirExists(Path path) |
private void |
ensureDirectoryExists(Path dir) |
boolean |
exists(Path path)
Tests if a path exists.
|
private boolean |
fileExists(Path path) |
PathAttributes |
getAttributes(Path path)
Get the
PathAttributes of an existing path. |
boolean |
isOpen()
Return if the connection to the FileSystem is open.
|
java.lang.Iterable<PathAttributes> |
list(Path path,
boolean recursive)
List all entries in the directory
dir . |
protected java.lang.Iterable<PathAttributes> |
listDirectory(Path dir)
Return the list of entries in a directory.
|
(package private) java.util.Iterator<PathAttributes> |
listNonRecursiveIterator(java.lang.String bucketEntry) |
private java.lang.Iterable<PathAttributes> |
listPrefix(java.lang.String prefix,
boolean recursive) |
private PathAttributes |
makeBlobAttributes(java.lang.String name) |
(package private) PathAttributes |
makeDirAttributes(org.jclouds.blobstore.domain.StorageMetadata m) |
private void |
makeDirectoryPlaceholder(Path dir) |
java.io.InputStream |
readFromFile(Path path)
Open an existing file and return an
InputStream to read from this file. |
Path |
readSymbolicLink(Path link)
Reads the target of a symbolic link (optional operation).
|
private void |
removeDirectoryPlaceholder(Path dir) |
void |
rename(Path source,
Path target)
Rename an existing source path to a non-existing target path (optional operation).
|
void |
setPosixFilePermissions(Path path,
java.util.Set<PosixFilePermission> permissions)
Sets the POSIX permissions of a path (optional operation).
|
(package private) java.lang.String |
toBucketEntry(Path path) |
(package private) PathAttributes |
toPathAttributes(org.jclouds.blobstore.domain.StorageMetadata m) |
java.io.OutputStream |
writeToFile(Path file)
Open a file and return an
OutputStream to write to this file. |
java.io.OutputStream |
writeToFile(Path path,
long size)
Open a file and return an
OutputStream to write to this file. |
areSamePaths, assertDirectoryExists, assertFileExists, assertFileIsSymbolicLink, assertIsOpen, assertNotNull, assertParentDirectoryExists, assertPathExists, assertPathIsDirectory, assertPathIsFile, assertPathIsNotDirectory, assertPathNotExists, cancel, copy, copyFile, copySymbolicLink, create, create, create, create, createDirectories, delete, equals, getAdaptorDescription, getAdaptorDescriptions, getAdaptorName, getAdaptorNames, getCredential, getLocation, getPathSeparator, getProperties, getStatus, getWorkingDirectory, hashCode, isDotDot, list, performCopy, setWorkingDirectory, streamCopy, toAbsolutePath, waitUntilDone
private static final java.lang.String NOT_EMPTY
final java.lang.String bucket
final org.jclouds.blobstore.BlobStoreContext context
final java.lang.String adaptorName
boolean open
public JCloudsFileSytem(java.lang.String uniqueID, java.lang.String adaptorName, java.lang.String endPoint, Credential credential, Path workingDir, org.jclouds.blobstore.BlobStoreContext context, java.lang.String bucket, int bufferSize, XenonProperties properties)
java.lang.String toBucketEntry(Path path)
public void close() throws XenonException
FileSystem
close
in interface java.lang.AutoCloseable
close
in class FileSystem
XenonException
- If the FileSystem failed to close or if an I/O error occurred.public boolean isOpen() throws XenonException
FileSystem
isOpen
in class FileSystem
XenonException
- if the test failed or an I/O error occurred.public void rename(Path source, Path target) throws XenonException
FileSystem
This method only implements a rename operation, not a move operation. Hence, this method will not copy files and should return (almost)
instantaneously.
The parent of the target path (e.g. target.getParent
) must exist.
If the target is equal to the source this method has no effect.
If the source is a link, the link itself will be renamed, not the path to which it refers.
If the source is a directory, it will be renamed to the target. This implies that a moving a directory between physical locations may fail.
rename
in class FileSystem
source
- the existing source path.target
- the non existing target path.UnsupportedOperationException
- If the adapter does not support renaming.NoSuchPathException
- If the source file does not exist or the target parent directory does not exist.PathAlreadyExistsException
- If the target file already exists.NotConnectedException
- If file system is closed.XenonException
- If the move failed.void checkClosed() throws XenonException
XenonException
public void createDirectory(Path dir) throws XenonException
FileSystem
createDirectory
in class FileSystem
dir
- the directory to create.PathAlreadyExistsException
- If the directory already exists.NoSuchPathException
- If the parent directory does not exist.NotConnectedException
- If file system is closed.XenonException
- If an I/O error occurred.private void makeDirectoryPlaceholder(Path dir)
private void removeDirectoryPlaceholder(Path dir)
public void createFile(Path file) throws XenonException
FileSystem
createFile
in class FileSystem
file
- a path referring to the file to create.PathAlreadyExistsException
- If the file already exists.NoSuchPathException
- If the parent directory does not exist.NotConnectedException
- If file system is closed.XenonException
- If an I/O error occurred.public void createSymbolicLink(Path link, Path target) throws XenonException
FileSystem
createSymbolicLink
in class FileSystem
link
- the symbolic link to create.target
- the target the symbolic link should refer to.PathAlreadyExistsException
- If the link already exists.NoSuchPathException
- If the target or parent directory of link does not existInvalidPathException
- If parent of link is not a directoryNotConnectedException
- If file system is closed.XenonException
- If an I/O error occurred.private void ensureDirectoryExists(Path dir)
public void deleteFile(Path file) throws XenonException
FileSystem
deleteFile
in class FileSystem
file
- the file to removeInvalidPathException
- if the provided path is not a file.NoSuchPathException
- if the provided file does not exist.XenonException
- If the file could not be removed.protected void deleteDirectory(Path dir) throws XenonException
FileSystem
rmdir
in Linux).
This operation must be implemented by the various implementations of FileSystem.deleteDirectory
in class FileSystem
dir
- the directory to removeInvalidPathException
- if the provided path is not a directory.NoSuchPathException
- if the provided path does not exist.XenonException
- If the directory could not be removed.protected java.lang.Iterable<PathAttributes> listDirectory(Path dir) throws XenonException
FileSystem
dir
will be returned as part of the list, but they will not be listed themselves.
This operation must be implemented by the various implementations of FileSystem.listDirectory
in class FileSystem
dir
- the directory to listIterable
that iterates over all entries in dir
XenonException
- If the list could not be retrieved.private boolean dirExists(Path path)
private boolean fileExists(Path path)
public boolean exists(Path path) throws XenonException
FileSystem
exists
in class FileSystem
path
- the path to test.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.PathAttributes makeDirAttributes(org.jclouds.blobstore.domain.StorageMetadata m)
private PathAttributes makeBlobAttributes(java.lang.String name)
PathAttributes toPathAttributes(org.jclouds.blobstore.domain.StorageMetadata m)
java.util.Iterator<PathAttributes> listNonRecursiveIterator(java.lang.String bucketEntry)
public java.lang.Iterable<PathAttributes> list(Path path, boolean recursive) throws XenonException
FileSystem
dir
.
All entries in the directory are returned, but subdirectories will not be traversed by default. Set recursive
to true
, include
the listing of all subdirectories.
Symbolic links are not followed.list
in class FileSystem
path
- the target directory.recursive
- should the list recursively traverse the subdirectories ?List
of PathAttributes
that iterates over all entries in the directory dir
.NoSuchPathException
- If a directory does not exists.InvalidPathException
- If dir
is not a directory.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.private java.lang.Iterable<PathAttributes> listPrefix(java.lang.String prefix, boolean recursive)
public java.io.InputStream readFromFile(Path path) throws XenonException
FileSystem
InputStream
to read from this file.readFromFile
in class FileSystem
path
- the to read.InputStream
to read from the file.NoSuchPathException
- If the file does not exists.InvalidPathException
- If the file is not regular file.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.public java.io.OutputStream writeToFile(Path path, long size) throws XenonException
FileSystem
OutputStream
to write to this file.
The size of the file (once all data has been written) must be specified using the size
parameter. This is required by some implementations
(typically blob-stores).
writeToFile
in class FileSystem
path
- the target file for the OutputStream.size
- the size of the file once fully written.OutputStream
to write to the file.PathAlreadyExistsException
- If the target existed.NoSuchPathException
- if a parent directory does not exist.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.public java.io.OutputStream writeToFile(Path file) throws XenonException
FileSystem
OutputStream
to write to this file. (optional operation)
If the file already exists it will be replaced and its data will be lost. The amount of data that will be written to the file is not specified in advance. This operation may not be supported by all implementations.
writeToFile
in class FileSystem
file
- the target file for the OutputStream.OutputStream
to write to the file.PathAlreadyExistsException
- If the target existed.NoSuchPathException
- if a parent directory does not exist.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.public java.io.OutputStream appendToFile(Path file) throws XenonException
FileSystem
OutputStream
to append data to this file. (optional operation)
If the file does not exist, an exception will be thrown. This operation may not be supported by all implementations.
appendToFile
in class FileSystem
file
- the target file for the OutputStream.OutputStream
to write to the file.PathAlreadyExistsException
- If the target existed.NoSuchPathException
- if a parent directory does not exist.InvalidPathException
- if not a regular fileNotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.UnsupportedOperationException
- if the adaptor does not support appendingpublic PathAttributes getAttributes(Path path) throws XenonException
FileSystem
PathAttributes
of an existing path.getAttributes
in class FileSystem
path
- the existing path.NoSuchPathException
- If the file does not exists.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.public Path readSymbolicLink(Path link) throws XenonException
FileSystem
readSymbolicLink
in class FileSystem
link
- the link to read.NoSuchPathException
- If the link does not exists.InvalidPathException
- If the source is not a link.UnsupportedOperationException
- If this FileSystem does not support symbolic links.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.public void setPosixFilePermissions(Path path, java.util.Set<PosixFilePermission> permissions) throws XenonException
FileSystem
setPosixFilePermissions
in class FileSystem
path
- the target path.permissions
- the permissions to set.NoSuchPathException
- If the target path does not exists.UnsupportedOperationException
- If this FileSystem does not support symbolic links.NotConnectedException
- If file system is closed.XenonException
- if an I/O error occurred.