Package de.dlr.proseo.storagemgr.posix
Class PosixStorage
java.lang.Object
de.dlr.proseo.storagemgr.posix.PosixStorage
- All Implemented Interfaces:
Storage
An implementation of the Storage interface for a POSIX-based file system,
providing functionality to interact with the storage system, that is
retrieving information about the storage, performing file operations, and
path conversion.
This class assumes a no-bucket concept for POSIX storage.
- Author:
- Denys Chaykovskiy
-
Constructor Summary
ConstructorsConstructorDescriptionNo bucket constructor initializing the storage with a basePath and sourcePath. -
Method Summary
Modifier and TypeMethodDescriptionaddFSPrefix(String path) Adds the file system prefix to the path.addFSPrefix(List<String> paths) Adds the file system prefix to the paths.booleanbucketExists(String bucketName) Checks if the bucket exists.createStorageFile(String relativePath, String content) Creates a physical storage file.delete(StorageFile storageFileOrDir) Deletes the file or directory recursively from the storage.Deletes the file or directory recursively from the storage.voiddeleteBucket(String bucket) Deletes the bucket from the storage.deleteFile(StorageFile storageFile) Deletes the storage file from the storage.download(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) Downloads the file or directory from the storage.downloadFile(StorageFile sourceFile, StorageFile targetFileOrDir) Downloads the file from the storage.booleanfileExists(StorageFile storageFile) Checks if the file exists.Gets the absolute base path (file system prefix + bucket + base path).Gets all files (absolute paths) from the storage.getAbsoluteFiles(String relativePath) Gets files (absolute paths) from the storage with the given prefix (folder).getAbsolutePath(String relativePath) Gets the absolute path (POSIX: /<storagePath>/<relativePath>).getAbsolutePath(List<String> relativePaths) Gets the absolute paths (POSIX: /<storagePath>/<relativePath>).Gets the base path.Gets the bucket.Gets the buckets from the storage.getFileContent(StorageFile storageFile) Gets the file content.longgetFileSize(StorageFile storageFile) Gets the file size.getInputStream(StorageFile storageFile) Gets the input stream from the file.Gets all files from the storage.getRelativeFiles(String relativePath) Gets files from the storage with the given prefix (folder).getRelativePath(String absolutePath) Gets the relative path from the absolute path using the base path list.getRelativePath(List<String> absolutePaths) Gets the relative paths from the absolute paths using the base path list.Gets the source path.getStorageFile(String relativePath) Gets the storage file.Gets the storage files.Gets the storage type.booleanisDirectory(StorageFile storageFileOrDir) Checks if the storage file or directory is a directory.booleanisFile(StorageFile storageFileOrDir) Checks if the storage file or directory is a file (no slash at the end of the path).voidSets the bucket.upload(StorageFile sourceFileOrDir) Uploads the file or directory recursively to the storage.upload(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) Uploads the file or directory recursively to the storage.uploadFile(StorageFile sourceFile) Uploads the file to the storage.uploadFile(StorageFile sourceFile, StorageFile targetFileOrDir) Uploads the file to the storage.uploadSourceFile(String relativeSourceFile) Uploads the source file to the storage.uploadSourceFileOrDir(String relativeSourceFileOrDir) Uploads the source file or directory recursively to the storage.
-
Constructor Details
-
PosixStorage
No bucket constructor initializing the storage with a basePath and sourcePath. It creates the necessary directories if they don't exist.- Parameters:
cfg- POSIX configuration
-
-
Method Details
-
getStorageType
Gets the storage type.- Specified by:
getStorageTypein interfaceStorage- Returns:
- the storage type
-
getBasePath
Gets the base path.- Specified by:
getBasePathin interfaceStorage- Returns:
- the base path
-
getAbsoluteBasePath
Gets the absolute base path (file system prefix + bucket + base path). In this no-bucket POSIX version, it returns the base path.- Specified by:
getAbsoluteBasePathin interfaceStorage- Returns:
- the absolute base path
-
getSourcePath
Gets the source path.- Specified by:
getSourcePathin interfaceStorage- Returns:
- the source path
-
setBucket
Sets the bucket. -
getBucket
Gets the bucket. -
getBuckets
Gets the buckets from the storage.- Specified by:
getBucketsin interfaceStorage- Returns:
- the list of buckets (one bucket)
-
bucketExists
Checks if the bucket exists. In the one-bucket concept, it compares with the current bucket.- Specified by:
bucketExistsin interfaceStorage- Parameters:
bucketName- the name of the bucket- Returns:
- true if the bucket exists
-
deleteBucket
Deletes the bucket from the storage.- Specified by:
deleteBucketin interfaceStorage- Parameters:
bucket- the bucket to delete- Throws:
IOException- if the bucket cannot be deleted
-
getRelativeFiles
Gets files from the storage with the given prefix (folder).- Specified by:
getRelativeFilesin interfaceStorage- Parameters:
relativePath- the prefix (folder) for searching in the storage- Returns:
- the list of files with the given prefix
-
getRelativeFiles
Gets all files from the storage.- Specified by:
getRelativeFilesin interfaceStorage- Returns:
- the list of all files from the storage
-
getAbsoluteFiles
Gets files (absolute paths) from the storage with the given prefix (folder).- Specified by:
getAbsoluteFilesin interfaceStorage- Parameters:
relativePath- the prefix (relative path) for searching in the storage- Returns:
- the list of files with the given prefix
-
getAbsoluteFiles
Gets all files (absolute paths) from the storage.- Specified by:
getAbsoluteFilesin interfaceStorage- Returns:
- the list of all files from the storage
-
getRelativePath
Gets the relative path from the absolute path using the base path list.- Specified by:
getRelativePathin interfaceStorage- Parameters:
absolutePath- the absolute path- Returns:
- the relative path
-
getRelativePath
Gets the relative paths from the absolute paths using the base path list.- Specified by:
getRelativePathin interfaceStorage- Parameters:
absolutePaths- the absolute paths- Returns:
- the relative paths
-
getAbsolutePath
Gets the absolute path (POSIX: /<storagePath>/<relativePath>).- Specified by:
getAbsolutePathin interfaceStorage- Parameters:
relativePath- the relative path- Returns:
- the absolute file depending on the storage file system
-
getAbsolutePath
Gets the absolute paths (POSIX: /<storagePath>/<relativePath>).- Specified by:
getAbsolutePathin interfaceStorage- Parameters:
relativePaths- the relative paths- Returns:
- the absolute paths depending on the storage file system
-
getStorageFile
Gets the storage file.- Specified by:
getStorageFilein interfaceStorage- Parameters:
relativePath- the relative path in storage to the file- Returns:
- the storage file object
-
getStorageFiles
Gets the storage files.- Specified by:
getStorageFilesin interfaceStorage- Returns:
- the list of storage files
-
createStorageFile
Creates a physical storage file.- Specified by:
createStorageFilein interfaceStorage- 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 the file cannot be created
-
fileExists
Checks if the file exists.- Specified by:
fileExistsin interfaceStorage- Parameters:
storageFile- the storage file to check- Returns:
- true if the file exists physically
-
isFile
Checks if the storage file or directory is a file (no slash at the end of the path). -
isDirectory
Checks if the storage file or directory is a directory.- Specified by:
isDirectoryin interfaceStorage- Parameters:
storageFileOrDir- the storage file or directory- Returns:
- true if the storage file is a file
-
getFileSize
Gets the file size.- Specified by:
getFileSizein interfaceStorage- Parameters:
storageFile- the storage file- Returns:
- the file size of the storage file
-
getFileContent
Gets the file content.- Specified by:
getFileContentin interfaceStorage- Parameters:
storageFile- the storage file- Returns:
- the file content
- Throws:
IOException- if an error occurs while getting the file content
-
uploadFile
Uploads the file to the storage.- Specified by:
uploadFilein interfaceStorage- Parameters:
sourceFile- the source file to uploadtargetFileOrDir- the target file or directory in the storage- Returns:
- the uploaded storage file
- Throws:
IOException- if the file cannot be uploaded
-
upload
public List<String> upload(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException Uploads the file or directory recursively to the storage.- Specified by:
uploadin interfaceStorage- Parameters:
sourceFileOrDir- the source file or directorytargetFileOrDir- the target file or directory in the storage- Returns:
- the list of uploaded files
- Throws:
IOException- if the file or directory cannot be uploaded
-
upload
Uploads the file or directory recursively to the storage.- Specified by:
uploadin interfaceStorage- Parameters:
sourceFileOrDir- the source file or dir to upload- Returns:
- the list of uploaded files
- Throws:
IOException- if the file or directory cannot be uploaded
-
uploadFile
Uploads the file to the storage.- Specified by:
uploadFilein interfaceStorage- Parameters:
sourceFile- the source file to upload- Returns:
- the path of the uploaded file
- Throws:
IOException- if the file cannot be uploaded
-
uploadSourceFileOrDir
Uploads the source file or directory recursively to the storage.- Specified by:
uploadSourceFileOrDirin interfaceStorage- Parameters:
relativeSourceFileOrDir- the relative path to source file or directory- Returns:
- the list of uploaded files to the storage
- Throws:
IOException- if the file or directory cannot be uploaded
-
uploadSourceFile
Uploads the source file to the storage.- Specified by:
uploadSourceFilein interfaceStorage- Parameters:
relativeSourceFile- the relative path to the source file- Returns:
- the uploaded source file
- Throws:
IOException- if the file cannot be uploaded
-
download
public List<String> download(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException Downloads the file or directory from the storage.- Specified by:
downloadin interfaceStorage- Parameters:
sourceFileOrDir- the storage source file or directory to downloadtargetFileOrDir- the target file or directory- Returns:
- the list of downloaded files
- Throws:
IOException- if the file cannot be downloaded
-
downloadFile
Downloads the file from the storage.- Specified by:
downloadFilein interfaceStorage- Parameters:
sourceFile- the storage source file to downloadtargetFileOrDir- the target file or directory- Returns:
- the downloaded storage file
- Throws:
IOException- if the file cannot be downloaded
-
delete
Deletes the file or directory recursively from the storage.- Specified by:
deletein interfaceStorage- Parameters:
storageFileOrDir- the storage file or directory to delete- Returns:
- the list of deleted files from the storage
- Throws:
IOException- if the file or directory cannot be deleted
-
deleteFile
Deletes the storage file from the storage.- Specified by:
deleteFilein interfaceStorage- Parameters:
storageFile- the storage file to delete- Returns:
- the deleted storage file
- Throws:
IOException- if the file cannot be deleted
-
delete
Deletes the file or directory recursively from the storage.- Specified by:
deletein interfaceStorage- 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 the file or directory cannot be deleted
-
addFSPrefix
Adds the file system prefix to the path.- Specified by:
addFSPrefixin interfaceStorage- Parameters:
path- the path to extend- Returns:
- the file system prefix + "|" + path
-
addFSPrefix
Adds the file system prefix to the paths.- Specified by:
addFSPrefixin interfaceStorage- Parameters:
paths- the paths to extend- Returns:
- the list of file system prefix + path
-
getInputStream
Gets the input stream from the file.- Specified by:
getInputStreamin interfaceStorage- Parameters:
storageFile- the storage file- Returns:
- the input stream from the file
- Throws:
IOException- if an error occurs while getting the input stream
-