Klasse S3Storage

java.lang.Object
de.dlr.proseo.storagemgr.s3.S3Storage
Alle implementierten Schnittstellen:
Storage

public class S3Storage extends Object implements Storage
An implementation of the Storage interface for a S3-based file system, providing functionality to interact with the storage system, that is retrieving information about the storage, performing file operations, and path conversion.
Autor:
Denys Chaykovskiy
  • Konstruktordetails

    • S3Storage

      public S3Storage(S3Configuration cfg) throws IOException
      Constructor with the s3 configuration
      Parameter:
      cfg - s3 configuration
      Löst aus:
      IOException - if an I/O exception occurs
  • Methodendetails

    • getStorageType

      public StorageType getStorageType()
      Gets the storage type.
      Angegeben von:
      getStorageType in Schnittstelle Storage
      Gibt zurück:
      the storage type
    • getBasePath

      public String getBasePath()
      Gets the base path.
      Angegeben von:
      getBasePath in Schnittstelle Storage
      Gibt zurück:
      the base path
    • getAbsoluteBasePath

      public String getAbsoluteBasePath()
      Gets the absolute base path (fs prefix + bucket + base path), depends on fs. In other words, it is the absolute path without the relative path in this S3 version. s3://bucket/
      Angegeben von:
      getAbsoluteBasePath in Schnittstelle Storage
      Gibt zurück:
      the absolute base path
    • getSourcePath

      public String getSourcePath()
      Gets the source path.
      Angegeben von:
      getSourcePath in Schnittstelle Storage
      Gibt zurück:
      the source path
    • setBucket

      public void setBucket(String bucket) throws IOException
      Sets the bucket.
      Angegeben von:
      setBucket in Schnittstelle Storage
      Parameter:
      bucket - the bucket to set
      Löst aus:
      IOException - if an I/O exception occurs
    • getBucket

      public String getBucket()
      Gets the bucket.
      Angegeben von:
      getBucket in Schnittstelle Storage
      Gibt zurück:
      the current bucket
    • getBuckets

      public List<String> getBuckets() throws IOException
      Gets the buckets from storage.
      Angegeben von:
      getBuckets in Schnittstelle Storage
      Gibt zurück:
      the list of buckets
      Löst aus:
      IOException - if an I/O exception occurs
    • bucketExists

      public boolean bucketExists(String bucketName) throws IOException
      Checks if the bucket exists.
      Angegeben von:
      bucketExists in Schnittstelle Storage
      Parameter:
      bucketName - the name of the bucket
      Gibt zurück:
      true if the bucket exists
      Löst aus:
      IOException - if an I/O exception occurs
    • deleteBucket

      public void deleteBucket(String bucketName) throws IOException
      Deletes the bucket in storage.
      Angegeben von:
      deleteBucket in Schnittstelle Storage
      Parameter:
      bucketName - the bucket to delete
      Löst aus:
      IOException - if the bucket cannot be deleted
    • getRelativeFiles

      public List<String> getRelativeFiles(String folder) throws IOException
      Gets the files from storage with the given prefix (folder).
      Angegeben von:
      getRelativeFiles in Schnittstelle Storage
      Parameter:
      folder - the prefix (folder) for search in storage
      Gibt zurück:
      the list of files with the given prefix
      Löst aus:
      IOException - if an I/O exception occurs
    • getRelativeFiles

      public List<String> getRelativeFiles() throws IOException
      Gets all files from storage.
      Angegeben von:
      getRelativeFiles in Schnittstelle Storage
      Gibt zurück:
      the list of all files from storage
      Löst aus:
      IOException - if an I/O exception occurs
    • getAbsoluteFiles

      public List<String> getAbsoluteFiles(String relativePath) throws IOException
      Gets files (absolute paths) from storage with the given relative path.
      Angegeben von:
      getAbsoluteFiles in Schnittstelle Storage
      Parameter:
      relativePath - the relative path for search in storage
      Gibt zurück:
      the list of files with the given prefix
      Löst aus:
      IOException - if an I/O exception occurs
    • getAbsoluteFiles

      public List<String> getAbsoluteFiles() throws IOException
      Gets all files (absolute paths) from storage.
      Angegeben von:
      getAbsoluteFiles in Schnittstelle Storage
      Gibt zurück:
      the list of all files from storage
      Löst aus:
      IOException - if an I/O exception occurs
    • getRelativePath

      public String getRelativePath(String absolutePath)
      Gets the relative path from the absolute path by removing the S3 prefix, bucket, and left slash.
      Angegeben von:
      getRelativePath in Schnittstelle Storage
      Parameter:
      absolutePath - the absolute path
      Gibt zurück:
      the relative path
    • getRelativePath

      public List<String> getRelativePath(List<String> absolutePaths)
      Gets the relative paths from the absolute paths by removing the S3 prefix, bucket, and left slash.
      Angegeben von:
      getRelativePath in Schnittstelle Storage
      Parameter:
      absolutePaths - the absolute paths
      Gibt zurück:
      the relative paths
    • getAbsolutePath

      public String getAbsolutePath(String relativePath)
      Gets the absolute path (s3://<bucket>/<relativePath>).
      Angegeben von:
      getAbsolutePath in Schnittstelle Storage
      Parameter:
      relativePath - the relative path
      Gibt zurück:
      the absolute file depending on the storage file system
    • getAbsolutePath

      public List<String> getAbsolutePath(List<String> relativePaths)
      Gets the absolute paths (s3://<bucket>/<relativePath>).
      Angegeben von:
      getAbsolutePath in Schnittstelle Storage
      Parameter:
      relativePaths - the relative paths
      Gibt zurück:
      the absolute paths depending on the storage file system
    • getStorageFile

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

      public List<StorageFile> getStorageFiles() throws IOException
      Gets the storage files.
      Angegeben von:
      getStorageFiles in Schnittstelle Storage
      Gibt zurück:
      the list of storage files
      Löst aus:
      IOException - if an I/O exception occurs
    • createStorageFile

      public StorageFile createStorageFile(String relativePath, String content) throws IOException
      Creates the physical storage file.
      Angegeben von:
      createStorageFile in Schnittstelle Storage
      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 the file cannot be created
    • fileExists

      public boolean fileExists(StorageFile storageFile) throws IOException
      Checks if the file exists.
      Angegeben von:
      fileExists in Schnittstelle Storage
      Parameter:
      storageFile - the storage file to check
      Gibt zurück:
      true if the file exists physically
      Löst aus:
      IOException - if an I/O exception occurs
    • isFile

      public boolean isFile(StorageFile storageFileOrDir) throws IOException
      Checks if the storage file or directory is a file (no slash at the end of the path).
      Angegeben von:
      isFile in Schnittstelle Storage
      Parameter:
      storageFileOrDir - the storage file or directory
      Gibt zurück:
      true if the storage file is a file
      Löst aus:
      IOException - if an I/O exception occurs
    • isDirectory

      public boolean isDirectory(StorageFile storageFileOrDir) throws IOException
      Checks if the storage file or directory is a directory.
      Angegeben von:
      isDirectory in Schnittstelle Storage
      Parameter:
      storageFileOrDir - the storage file or directory
      Gibt zurück:
      true if the storage file is a file
      Löst aus:
      IOException - if an I/O exception occurs
    • getFileSize

      public long getFileSize(StorageFile storageFile) throws IOException
      Gets the file size.
      Angegeben von:
      getFileSize in Schnittstelle Storage
      Parameter:
      storageFile - the storage file
      Gibt zurück:
      the file size of the storage file
      Löst aus:
      IOException - if an I/O exception occurs
    • getFileContent

      public String getFileContent(StorageFile storageFile) throws IOException
      Gets the file content.
      Angegeben von:
      getFileContent in Schnittstelle Storage
      Parameter:
      storageFile - the storage file
      Gibt zurück:
      the file content
      Löst aus:
      IOException - if an error occurs while getting the file content
    • uploadFile

      public String uploadFile(StorageFile sourceFile, StorageFile targetFileOrDir) throws IOException
      Uploads the file to storage.
      Angegeben von:
      uploadFile in Schnittstelle Storage
      Parameter:
      sourceFile - the source file to upload
      targetFileOrDir - the target file or directory in the storage
      Gibt zurück:
      the uploaded storage file
      Löst aus:
      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 storage.
      Angegeben von:
      upload in Schnittstelle 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 the file or directory cannot be uploaded
    • upload

      public List<String> upload(StorageFile sourceFileOrDir) throws IOException
      Uploads the file or directory recursively to the storage.
      Angegeben von:
      upload in Schnittstelle Storage
      Parameter:
      sourceFileOrDir - the source file or dir to upload
      Gibt zurück:
      the list of uploaded files
      Löst aus:
      IOException - if the file or directory cannot be uploaded
    • uploadFile

      public String uploadFile(StorageFile sourceFile) throws IOException
      Uploads the file to the storage.
      Angegeben von:
      uploadFile in Schnittstelle Storage
      Parameter:
      sourceFile - the source file to upload
      Gibt zurück:
      the path of the uploaded file
      Löst aus:
      IOException - if the file cannot be uploaded
    • uploadSourceFileOrDir

      public List<String> uploadSourceFileOrDir(String relativeSourceFileOrDir) throws IOException
      Uploads the source file or directory recursively to the storage.
      Angegeben von:
      uploadSourceFileOrDir in Schnittstelle Storage
      Parameter:
      relativeSourceFileOrDir - the relative path to source file or directory
      Gibt zurück:
      the list of uploaded to storage source files
      Löst aus:
      IOException - if the file cannot be uploaded
    • uploadSourceFile

      public String uploadSourceFile(String relativeSourceFile) throws IOException
      Uploads the source file.
      Angegeben von:
      uploadSourceFile in Schnittstelle Storage
      Parameter:
      relativeSourceFile - the relative path to source file
      Gibt zurück:
      the uploaded to storage source file
      Löst aus:
      IOException - if the file cannot be uploaded
    • download

      public List<String> download(StorageFile sourceFileOrDir, StorageFile targetFileOrDir) throws IOException
      Downloads the file or directory recursively.
      Angegeben von:
      download in Schnittstelle 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 the file cannot be downloaded
    • downloadFile

      public String downloadFile(StorageFile sourceFile, StorageFile targetFileOrDir) throws IOException
      Downloads the file from storage.
      Angegeben von:
      downloadFile in Schnittstelle Storage
      Parameter:
      sourceFile - the storage source file to download
      targetFileOrDir - the target file or directory
      Gibt zurück:
      the Storage File object with the downloaded file
      Löst aus:
      IOException - if the file cannot be downloaded
    • delete

      public List<String> delete(StorageFile storageFileOrDir) throws IOException
      Deletes the file or directory recursively from the storage.
      Angegeben von:
      delete in Schnittstelle Storage
      Parameter:
      storageFileOrDir - the Storage file or directory to delete
      Gibt zurück:
      the list of deleted files from storage
      Löst aus:
      IOException - if the file or directory cannot be deleted
    • deleteFile

      public String deleteFile(StorageFile storageFile) throws IOException
      Deletes the storage file from storage.
      Angegeben von:
      deleteFile in Schnittstelle Storage
      Parameter:
      storageFile - the storage file to delete
      Gibt zurück:
      the deleted storage file
      Löst aus:
      IOException - if the file cannot be deleted
    • delete

      public List<String> delete(String relativeFileOrDir) throws IOException
      Deletes the file or directory recursively from the storage.
      Angegeben von:
      delete in Schnittstelle Storage
      Parameter:
      relativeFileOrDir - the Storage file or directory to delete
      Gibt zurück:
      the list of deleted files from storage
      Löst aus:
      IOException - if the file or directory cannot be deleted
    • addFSPrefix

      public String addFSPrefix(String path)
      Adds the file system prefix to the path.
      Angegeben von:
      addFSPrefix in Schnittstelle Storage
      Parameter:
      path - the path to extend
      Gibt zurück:
      the file system prefix + "|" + path
    • addFSPrefix

      public List<String> addFSPrefix(List<String> paths)
      Adds the file system prefix to paths.
      Angegeben von:
      addFSPrefix in Schnittstelle Storage
      Parameter:
      paths - the paths to extend
      Gibt zurück:
      the list of file system prefix + path
    • getInputStream

      public InputStream getInputStream(StorageFile storageFile) throws IOException
      Gets the input stream from the file.
      Angegeben von:
      getInputStream in Schnittstelle Storage
      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