Package de.dlr.proseo.storagemgr.model
Interface Storage
- All Known Implementing Classes:
PosixStorage,S3Storage
public interface Storage
A high-level interface for performing common operations on a storage system,
abstracting away the underlying implementation details. It provides methods
for retrieving information on the storage, managing buckets, and working with
files and directories, as well as utility methods to add a file system prefix
to a path and a list of paths.
Implementations of this interface should provide the necessary logic to
interact with specific storage systems, such as POSIX or S3.
- Author:
- Denys Chaykovskiy
-
Method Summary
Modifier and TypeMethodDescriptionaddFSPrefix(String path) Adds a file system prefix to the path.addFSPrefix(List<String> paths) Adds a file system prefix and bucket to paths.booleanbucketExists(String bucketName) Checks if the bucket exists.createStorageFile(String relativePath, String content) Physically creates a storage file.delete(StorageFile storageFileOrDir) Deletes a file or directory recursively from the storage.Deletes a file or directory recursively from the storage.voiddeleteBucket(String bucket) Deletes a bucket in the storage.deleteFile(StorageFile storageFileOrDir) Deletes a storage file from the storage.download(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) Downloads a file or directory recursively from the storage.downloadFile(StorageFile sourceFile, StorageFile targetFileOrDir) Downloads a file from the storage.booleanfileExists(StorageFile storageFile) Checks if a file exists.Gets the absolute base path (file system prefix + bucket + base path), depending on the file system.Gets all files (absolute paths) from the storage.getAbsoluteFiles(String prefix) Gets the files (absolute paths) from the storage with the given prefix (folder).getAbsolutePath(String relativePath) Gets the absolute path depending on the storage file system.getAbsolutePath(List<String> relativePaths) Gets the absolute paths depending on the storage file system.Gets the base path, which is the root directory of the storage system.Gets the current bucket.Gets the buckets from the storage.getFileContent(StorageFile storageFile) Gets the content of the specified storage file.longgetFileSize(StorageFile storageFile) Gets the file size.getInputStream(StorageFile storageFile) Gets the input stream from a file.Gets all files (relative paths) from the storage.getRelativeFiles(String prefix) Gets files (relative paths) from the storage with the given prefix (folder).getRelativePath(String absolutePath) Gets the relative path from the absolute path.getRelativePath(List<String> absolutePaths) Gets the relative paths from the absolute paths.Gets the source path.getStorageFile(String relativePath) Gets the storage file.Gets the storage files.Gets the storage type, e.g.booleanisDirectory(StorageFile storageFileOrDir) Checks if the storage file or directory is a directory.booleanisFile(StorageFile storageFileOrDir) Checks if a storage file or directory is a file (i.e., no slash at the end of the path).voidSets the bucket.upload(StorageFile sourceFileOrDir) Uploads a file or directory recursively to the storage.upload(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) Uploads a file or directory recursively to the storage.uploadFile(StorageFile sourceFile) Uploads a file to the storage.uploadFile(StorageFile sourceFile, StorageFile targetFileOrDir) Uploads a file to the storage.uploadSourceFile(String relativeSourceFile) Uploads a source file to the storage.uploadSourceFileOrDir(String relativeSourceFileOrDir) Uploads a source file or directory recursively to the storage.
-
Method Details
-
getStorageType
StorageType getStorageType()Gets the storage type, e.g. POSIX or S3.- Returns:
- the storage type
-
getBasePath
String getBasePath()Gets the base path, which is the root directory of the storage system.- Returns:
- the base path
-
getAbsoluteBasePath
String getAbsoluteBasePath()Gets the absolute base path (file system prefix + bucket + base path), depending on the file system.- Returns:
- the absolute base path
-
getSourcePath
String getSourcePath()Gets the source path.- Returns:
- the source path
-
setBucket
Sets the bucket.- Parameters:
bucket- the bucket to set- Throws:
IOException- if an error occurs while setting the bucket
-
getBucket
String getBucket()Gets the current bucket.- Returns:
- the current bucket
-
getBuckets
Gets the buckets from the storage.- Returns:
- the list of buckets
- Throws:
IOException- if an error occurs while getting the buckets
-
bucketExists
Checks if the bucket exists.- Parameters:
bucketName- the name of the bucket- Returns:
- true if the bucket exists
- Throws:
IOException- if an error occurs while checking the bucket existence
-
deleteBucket
Deletes a bucket in the storage.- Parameters:
bucket- the bucket to delete- Throws:
IOException- if an error occurs while deleting the bucket
-
getRelativeFiles
Gets files (relative paths) from the storage with the given prefix (folder).- Parameters:
prefix- the prefix (folder) to search in the storage- Returns:
- the list of files starting with the given prefix
- Throws:
IOException- if an error occurs while getting the relative files
-
getRelativeFiles
Gets all files (relative paths) from the storage.- Returns:
- the list of all files from the storage
- Throws:
IOException- if an error occurs while getting the relative files
-
getAbsoluteFiles
Gets the files (absolute paths) from the storage with the given prefix (folder).- Parameters:
prefix- the prefix (folder) to search in the storage- Returns:
- the list of files starting with the given prefix
- Throws:
IOException- if an error occurs while getting the absolute files
-
getAbsoluteFiles
Gets all files (absolute paths) from the storage.- Returns:
- the list of all files from the storage
- Throws:
IOException- if an error occurs while getting the absolute files
-
getRelativePath
Gets the relative path from the absolute path.- Parameters:
absolutePath- the absolute path- Returns:
- the relative path
-
getRelativePath
Gets the relative paths from the absolute paths.- Parameters:
absolutePaths- the absolute paths- Returns:
- the relative paths
-
getAbsolutePath
Gets the absolute path depending on the storage file system.- Parameters:
relativePath- the relative path- Returns:
- the absolute file depending on the storage file system
-
getAbsolutePath
Gets the absolute paths depending on the storage file system.- Parameters:
relativePaths- the relative paths- Returns:
- the absolute paths depending on the storage file system
-
getStorageFile
Gets the storage file.- Parameters:
relativePath- the relative path in the storage to the file- Returns:
- the storage file object
-
getStorageFiles
Gets the storage files.- Returns:
- the list of storage files
- Throws:
IOException- if an error occurs while getting the storage files
-
createStorageFile
Physically creates a storage file.- Parameters:
relativePath- the relative path of the filecontent- the content of the file- Returns:
- the storage file object of the created file
- Throws:
IOException- if an error occurs while creating the storage file
-
fileExists
Checks if a file exists.- Parameters:
storageFile- the storage file to check- Returns:
- true if the file exists physically
- Throws:
IOException- if an error occurs while checking the file existence
-
isFile
Checks if a storage file or directory is a file (i.e., no slash at the end of the path).- Parameters:
storageFileOrDir- the storage file or directory- Returns:
- true if the storage file is a file
- Throws:
IOException- if an error occurs while checking if the storage file is a file
-
isDirectory
Checks if the storage file or directory is a directory.- Parameters:
storageFileOrDir- the storage file or directory- Returns:
- true if the storage file is a directory
- Throws:
IOException- if an error occurs while checking if the storage file is a directory
-
getFileSize
Gets the file size.- Parameters:
storageFile- the storage file- Returns:
- the file size of the storage file
- Throws:
IOException- if an error occurs while getting the file size
-
getFileContent
Gets the content of the specified storage file.- Parameters:
storageFile- the storage file from which to retrieve the content- Returns:
- the file content
- Throws:
IOException- if an error occurs while getting the file content
-
uploadFile
Uploads a file to the storage.- Parameters:
sourceFile- the source file to uploadtargetFileOrDir- the target file or directory in the storage- Returns:
- the path of the uploaded file
- Throws:
IOException- if an error occurs while uploading the file
-
upload
Uploads a file or directory recursively to the storage.- Parameters:
sourceFileOrDir- the source file or directorytargetFileOrDir- the target file or directory in the storage- Returns:
- the list of uploaded files
- Throws:
IOException- if an error occurs while uploading the file or directory
-
upload
Uploads a file or directory recursively to the storage.- Parameters:
sourceFileOrDir- the source file or directory to upload- Returns:
- the list of uploaded files
- Throws:
IOException- if an error occurs while uploading the file or directory
-
uploadFile
Uploads a file to the storage.- Parameters:
sourceFile- the source file to upload- Returns:
- the path of the uploaded file
- Throws:
IOException- if an error occurs while uploading the file
-
uploadSourceFileOrDir
Uploads a source file or directory recursively to the storage.- Parameters:
relativeSourceFileOrDir- the relative path to the source file or directory- Returns:
- the list of uploaded source files to the storage
- Throws:
IOException- if an error occurs while uploading the file
-
uploadSourceFile
Uploads a source file to the storage.- Parameters:
relativeSourceFile- the relative path to the source file- Returns:
- the uploaded source file in the storage
- Throws:
IOException- if an error occurs while uploading the file
-
download
Downloads a file or directory recursively from the storage.- Parameters:
sourceFileOrDir- the source file or directory in the storagetargetFileOrDir- the target file or directory- Returns:
- the list of downloaded files
- Throws:
IOException- if an error occurs while downloading the file or directory
-
downloadFile
Downloads a file from the storage.- Parameters:
sourceFile- the source file in the storage to downloadtargetFileOrDir- the target file or directory- Returns:
- the downloaded storage file
- Throws:
IOException- if an error occurs while downloading the file
-
delete
Deletes a file or directory recursively from the storage.- Parameters:
storageFileOrDir- the storage file or directory to delete- Returns:
- the list of deleted files from the storage
- Throws:
IOException- if an error occurs while deleting the file or directory
-
deleteFile
Deletes a storage file from the storage.- Parameters:
storageFileOrDir- the storage file to delete- Returns:
- the deleted storage file
- Throws:
IOException- if an error occurs while deleting the file
-
delete
Deletes a file or directory recursively from the storage.- Parameters:
relativeFileOrDir- the relative path to the storage file or directory to delete- Returns:
- the list of deleted files from the storage
- Throws:
IOException- if an error occurs while deleting the file or directory
-
addFSPrefix
Adds a file system prefix to the path.- Parameters:
path- the path to extend- Returns:
- the file system prefix + path
-
addFSPrefix
Adds a file system prefix and bucket to paths.- Parameters:
paths- the paths to extend- Returns:
- the list of file system prefix + path
-
getInputStream
Gets the input stream from a file.- Parameters:
storageFile- the storage file- Returns:
- the input stream from the file
- Throws:
IOException- if an error occurs while getting the input stream
-