Package com.exasol.bucketfs
Class ReadEnabledBucket
- java.lang.Object
-
- com.exasol.bucketfs.ReadEnabledBucket
-
- All Implemented Interfaces:
ReadOnlyBucket
- Direct Known Subclasses:
WriteEnabledBucket
public class ReadEnabledBucket extends Object implements ReadOnlyBucket
Bucket that support read access like listing contents and downloading files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReadEnabledBucket.Builder<T extends ReadEnabledBucket.Builder<T>>Builder forReadEnabledBucketobjects.
-
Field Summary
Fields Modifier and Type Field Description protected StringbucketNamebucket nameprotected StringhostHost or IP addressprotected intportportprotected StringreadPasswordread passwordprotected StringserviceNamebucketFs nameprotected Map<String,Instant>uploadHistoryupload history
-
Constructor Summary
Constructors Modifier Constructor Description protectedReadEnabledBucket(ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>> builder)Create a new instance of a bucket that support reading.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>>builder()Returns a builder.voiddownloadFile(String pathInBucket, Path localPath)Download a file from a bucket to a local filesystem.StringdownloadFileAsString(String pathInBucket)Download a file from a bucket into a string.protected StringextendPathInBucketDownToFilename(Path localPath, String pathInBucket)Extends path in bucket down to filename.StringgetBucketFsName()StringgetBucketName()protected HttpClientgetClient()Get the http client.StringgetFullyQualifiedBucketName()Get the fully qualified name of the bucket.StringgetReadPassword()Get the read password for the bucket.List<String>listContents()List the contents of a bucket.List<String>listContents(String path)List the contents of a path inside a bucket.List<String>listContentsRecursively()Recursively list the contents of a bucket.List<String>listContentsRecursively(String path)Recursively list the contents of a path inside a bucket.StringtoString()
-
-
-
Constructor Detail
-
ReadEnabledBucket
protected ReadEnabledBucket(ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>> builder)
Create a new instance of a bucket that support reading.- Parameters:
builder- builder from which the bucket should be constructed
-
-
Method Detail
-
getBucketFsName
public String getBucketFsName()
- Specified by:
getBucketFsNamein interfaceReadOnlyBucket- Returns:
- name of the BucketFS filesystem this bucket belongs to
-
getBucketName
public String getBucketName()
- Specified by:
getBucketNamein interfaceReadOnlyBucket- Returns:
- name of the bucket
-
getFullyQualifiedBucketName
public String getFullyQualifiedBucketName()
Description copied from interface:ReadOnlyBucketGet the fully qualified name of the bucket.- Specified by:
getFullyQualifiedBucketNamein interfaceReadOnlyBucket- Returns:
- fully qualified name consisting of service name and bucket name
-
getReadPassword
public String getReadPassword()
Description copied from interface:ReadOnlyBucketGet the read password for the bucket.- Specified by:
getReadPasswordin interfaceReadOnlyBucket- Returns:
- read password
-
listContents
public List<String> listContents() throws BucketAccessException
Description copied from interface:ReadOnlyBucketList the contents of a bucket.- Specified by:
listContentsin interfaceReadOnlyBucket- Returns:
- bucket contents
- Throws:
BucketAccessException- if the contents are not accessible or the path is invalid
-
listContentsRecursively
public List<String> listContentsRecursively() throws BucketAccessException
Description copied from interface:ReadOnlyBucketRecursively list the contents of a bucket.- Specified by:
listContentsRecursivelyin interfaceReadOnlyBucket- Returns:
- bucket contents
- Throws:
BucketAccessException- if the contents are not accessible or the path is invalid
-
listContents
public List<String> listContents(String path) throws BucketAccessException
Description copied from interface:ReadOnlyBucketList the contents of a path inside a bucket.- Specified by:
listContentsin interfaceReadOnlyBucket- Parameters:
path- relative path from the bucket root- Returns:
- list of file system entries
- Throws:
BucketAccessException- if the contents are not accessible or the path is invalid
-
listContentsRecursively
public List<String> listContentsRecursively(String path) throws BucketAccessException
Description copied from interface:ReadOnlyBucketRecursively list the contents of a path inside a bucket.- Specified by:
listContentsRecursivelyin interfaceReadOnlyBucket- Parameters:
path- relative path from the bucket root- Returns:
- list of file system entries
- Throws:
BucketAccessException- if the contents are not accessible or the path is invalid
-
extendPathInBucketDownToFilename
protected String extendPathInBucketDownToFilename(Path localPath, String pathInBucket)
Extends path in bucket down to filename.- Parameters:
localPath- localPathpathInBucket- pathInBucket- Returns:
- String
-
downloadFile
public void downloadFile(String pathInBucket, Path localPath) throws BucketAccessException
Description copied from interface:ReadOnlyBucketDownload a file from a bucket to a local filesystem.- Specified by:
downloadFilein interfaceReadOnlyBucket- Parameters:
pathInBucket- path of the file in BucketFSlocalPath- local path the file is downloaded to- Throws:
BucketAccessException- if the local file does not exist or is not accessible or if the download failed
-
downloadFileAsString
public String downloadFileAsString(String pathInBucket) throws BucketAccessException
Description copied from interface:ReadOnlyBucketDownload a file from a bucket into a string.- Specified by:
downloadFileAsStringin interfaceReadOnlyBucket- Parameters:
pathInBucket- path of the file in BucketFS- Returns:
- file contents as string
- Throws:
BucketAccessException- if the local file does not exist or is not accessible or if the download failed
-
getClient
protected HttpClient getClient()
Get the http client.- Returns:
- http client
-
builder
public static ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>> builder()
Returns a builder.- Returns:
- builder
-
-