Schnittstelle Storage

Alle bekannten Implementierungsklassen:
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.
Autor:
Denys Chaykovskiy
  • Methodendetails

    • getStorageType

      StorageType getStorageType()
      Gets the storage type, e.g. POSIX or S3.
      Gibt zurück:
      the storage type
    • getBasePath

      String getBasePath()
      Gets the base path, which is the root directory of the storage system.
      Gibt zurück:
      the base path
    • getAbsoluteBasePath

      String getAbsoluteBasePath()
      Gets the absolute base path (file system prefix + bucket + base path), depending on the file system.
      Gibt zurück:
      the absolute base path
    • getSourcePath

      String getSourcePath()
      Gets the source path.
      Gibt zurück:
      the source path
    • setBucket

      void setBucket(String bucket) throws IOException
      Sets the bucket.
      Parameter:
      bucket - the bucket to set
      Löst aus:
      IOException - if an error occurs while setting the bucket
    • getBucket

      String getBucket()
      Gets the current bucket.
      Gibt zurück:
      the current bucket
    • getBuckets

      List<String> getBuckets() throws IOException
      Gets the buckets from the storage.
      Gibt zurück:
      the list of buckets
      Löst aus:
      IOException - if an error occurs while getting the buckets
    • bucketExists

      boolean bucketExists(String bucketName) throws IOException
      Checks if the bucket exists.
      Parameter:
      bucketName - the name of the bucket
      Gibt zurück:
      true if the bucket exists
      Löst aus:
      IOException - if an error occurs while checking the bucket existence
    • deleteBucket

      void deleteBucket(String bucket) throws IOException
      Deletes a bucket in the storage.
      Parameter:
      bucket - the bucket to delete
      Löst aus:
      IOException - if an error occurs while deleting the bucket
    • getRelativeFiles

      List<String> getRelativeFiles(String prefix) throws IOException
      Gets files (relative paths) from the storage with the given prefix (folder).
      Parameter:
      prefix - the prefix (folder) to search in the storage
      Gibt zurück:
      the list of files starting with the given prefix
      Löst aus:
      IOException - if an error occurs while getting the relative files
    • getRelativeFiles

      List<String> getRelativeFiles() throws IOException
      Gets all files (relative paths) from the storage.
      Gibt zurück:
      the list of all files from the storage
      Löst aus:
      IOException - if an error occurs while getting the relative files
    • getAbsoluteFiles

      List<String> getAbsoluteFiles(String prefix) throws IOException
      Gets the files (absolute paths) from the storage with the given prefix (folder).
      Parameter:
      prefix - the prefix (folder) to search in the storage
      Gibt zurück:
      the list of files starting with the given prefix
      Löst aus:
      IOException - if an error occurs while getting the absolute files
    • getAbsoluteFiles

      List<String> getAbsoluteFiles() throws IOException
      Gets all files (absolute paths) from the storage.
      Gibt zurück:
      the list of all files from the storage
      Löst aus:
      IOException - if an error occurs while getting the absolute files
    • getRelativePath

      String getRelativePath(String absolutePath)
      Gets the relative path from the absolute path.
      Parameter:
      absolutePath - the absolute path
      Gibt zurück:
      the relative path
    • getRelativePath

      List<String> getRelativePath(List<String> absolutePaths)
      Gets the relative paths from the absolute paths.
      Parameter:
      absolutePaths - the absolute paths
      Gibt zurück:
      the relative paths
    • getAbsolutePath

      String getAbsolutePath(String relativePath)
      Gets the absolute path depending on the storage file system.
      Parameter:
      relativePath - the relative path
      Gibt zurück:
      the absolute file depending on the storage file system
    • getAbsolutePath

      List<String> getAbsolutePath(List<String> relativePaths)
      Gets the absolute paths depending on the storage file system.
      Parameter:
      relativePaths - the relative paths
      Gibt zurück:
      the absolute paths depending on the storage file system
    • getStorageFile

      StorageFile getStorageFile(String relativePath)
      Gets the storage file.
      Parameter:
      relativePath - the relative path in the storage to the file
      Gibt zurück:
      the storage file object
    • getStorageFiles

      List<StorageFile> getStorageFiles() throws IOException
      Gets the storage files.
      Gibt zurück:
      the list of storage files
      Löst aus:
      IOException - if an error occurs while getting the storage files
    • createStorageFile

      StorageFile createStorageFile(String relativePath, String content) throws IOException
      Physically creates a storage file.
      Parameter:
      relativePath - the relative path of the file
      content - the content of the file
      Gibt zurück:
      the storage file object of the created file
      Löst aus:
      IOException - if an error occurs while creating the storage file
    • fileExists

      boolean fileExists(StorageFile storageFile) throws IOException
      Checks if a file exists.
      Parameter:
      storageFile - the storage file to check
      Gibt zurück:
      true if the file exists physically
      Löst aus:
      IOException - if an error occurs while checking the file existence
    • isFile

      boolean isFile(StorageFile storageFileOrDir) throws IOException
      Checks if a storage file or directory is a file (i.e., no slash at the end of the path).
      Parameter:
      storageFileOrDir - the storage file or directory
      Gibt zurück:
      true if the storage file is a file
      Löst aus:
      IOException - if an error occurs while checking if the storage file is a file
    • isDirectory

      boolean isDirectory(StorageFile storageFileOrDir) throws IOException
      Checks if the storage file or directory is a directory.
      Parameter:
      storageFileOrDir - the storage file or directory
      Gibt zurück:
      true if the storage file is a directory
      Löst aus:
      IOException - if an error occurs while checking if the storage file is a directory
    • getFileSize

      long getFileSize(StorageFile storageFile) throws IOException
      Gets the file size.
      Parameter:
      storageFile - the storage file
      Gibt zurück:
      the file size of the storage file
      Löst aus:
      IOException - if an error occurs while getting the file size
    • getFileContent

      String getFileContent(StorageFile storageFile) throws IOException
      Gets the content of the specified storage file.
      Parameter:
      storageFile - the storage file from which to retrieve the content
      Gibt zurück:
      the file content
      Löst aus:
      IOException - if an error occurs while getting the file content
    • uploadFile

      String uploadFile(StorageFile sourceFile, StorageFile targetFileOrDir) throws IOException
      Uploads a file to the storage.
      Parameter:
      sourceFile - the source file to upload
      targetFileOrDir - the target file or directory in the storage
      Gibt zurück:
      the path of the uploaded file
      Löst aus:
      IOException - if an error occurs while uploading the file
    • upload

      List<String> upload(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException
      Uploads a file or directory recursively to the storage.
      Parameter:
      sourceFileOrDir - the source file or directory
      targetFileOrDir - the target file or directory in the storage
      Gibt zurück:
      the list of uploaded files
      Löst aus:
      IOException - if an error occurs while uploading the file or directory
    • upload

      List<String> upload(StorageFile sourceFileOrDir) throws IOException
      Uploads a file or directory recursively to the storage.
      Parameter:
      sourceFileOrDir - the source file or directory to upload
      Gibt zurück:
      the list of uploaded files
      Löst aus:
      IOException - if an error occurs while uploading the file or directory
    • uploadFile

      String uploadFile(StorageFile sourceFile) throws IOException
      Uploads a file to the storage.
      Parameter:
      sourceFile - the source file to upload
      Gibt zurück:
      the path of the uploaded file
      Löst aus:
      IOException - if an error occurs while uploading the file
    • uploadSourceFileOrDir

      List<String> uploadSourceFileOrDir(String relativeSourceFileOrDir) throws IOException
      Uploads a source file or directory recursively to the storage.
      Parameter:
      relativeSourceFileOrDir - the relative path to the source file or directory
      Gibt zurück:
      the list of uploaded source files to the storage
      Löst aus:
      IOException - if an error occurs while uploading the file
    • uploadSourceFile

      String uploadSourceFile(String relativeSourceFile) throws IOException
      Uploads a source file to the storage.
      Parameter:
      relativeSourceFile - the relative path to the source file
      Gibt zurück:
      the uploaded source file in the storage
      Löst aus:
      IOException - if an error occurs while uploading the file
    • download

      List<String> download(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException
      Downloads a file or directory recursively from the storage.
      Parameter:
      sourceFileOrDir - the source file or directory in the storage
      targetFileOrDir - the target file or directory
      Gibt zurück:
      the list of downloaded files
      Löst aus:
      IOException - if an error occurs while downloading the file or directory
    • downloadFile

      String downloadFile(StorageFile sourceFile, StorageFile targetFileOrDir) throws IOException
      Downloads a file from the storage.
      Parameter:
      sourceFile - the source file in the storage to download
      targetFileOrDir - the target file or directory
      Gibt zurück:
      the downloaded storage file
      Löst aus:
      IOException - if an error occurs while downloading the file
    • delete

      List<String> delete(StorageFile storageFileOrDir) throws IOException
      Deletes a file or directory recursively from the storage.
      Parameter:
      storageFileOrDir - the storage file or directory to delete
      Gibt zurück:
      the list of deleted files from the storage
      Löst aus:
      IOException - if an error occurs while deleting the file or directory
    • deleteFile

      String deleteFile(StorageFile storageFileOrDir) throws IOException
      Deletes a storage file from the storage.
      Parameter:
      storageFileOrDir - the storage file to delete
      Gibt zurück:
      the deleted storage file
      Löst aus:
      IOException - if an error occurs while deleting the file
    • delete

      List<String> delete(String relativeFileOrDir) throws IOException
      Deletes a file or directory recursively from the storage.
      Parameter:
      relativeFileOrDir - the relative path to the storage file or directory to delete
      Gibt zurück:
      the list of deleted files from the storage
      Löst aus:
      IOException - if an error occurs while deleting the file or directory
    • addFSPrefix

      String addFSPrefix(String path)
      Adds a file system prefix to the path.
      Parameter:
      path - the path to extend
      Gibt zurück:
      the file system prefix + path
    • addFSPrefix

      List<String> addFSPrefix(List<String> paths)
      Adds a file system prefix and bucket to paths.
      Parameter:
      paths - the paths to extend
      Gibt zurück:
      the list of file system prefix + path
    • getInputStream

      InputStream getInputStream(StorageFile storageFile) throws IOException
      Gets the input stream from a file.
      Parameter:
      storageFile - the storage file
      Gibt zurück:
      the input stream from the file
      Löst aus:
      IOException - if an error occurs while getting the input stream