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 StringbucketFsNameprotected StringbucketNameprotected HttpClientclientprotected StringipAddressprotected intportprotected StringreadPasswordprotected Map<String,Instant>uploadHistory
-
Constructor Summary
Constructors Modifier Constructor Description protectedReadEnabledBucket(ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>>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 voidevaluateRequestStatus(URI uri, BucketOperation operation, int statusCode)protected StringextendPathInBucketDownToFilename(Path localPath, String pathInBucket)StringgetBucketFsName()StringgetBucketName()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.StringtoString()
-
-
-
Field Detail
-
bucketFsName
protected final String bucketFsName
-
bucketName
protected final String bucketName
-
ipAddress
protected final String ipAddress
-
port
protected final int port
-
readPassword
protected final String readPassword
-
client
protected final HttpClient client
-
-
Constructor Detail
-
ReadEnabledBucket
protected ReadEnabledBucket(ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>> builder)
-
-
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
-
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
-
extendPathInBucketDownToFilename
protected String extendPathInBucketDownToFilename(Path localPath, String pathInBucket)
-
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
-
evaluateRequestStatus
protected void evaluateRequestStatus(URI uri, BucketOperation operation, int statusCode) throws BucketAccessException
- Throws:
BucketAccessException
-
builder
public static ReadEnabledBucket.Builder<? extends ReadEnabledBucket.Builder<?>> builder()
-
-