Klasse S3DAL

java.lang.Object
de.dlr.proseo.storagemgr.s3.S3DAL

public class S3DAL extends Object
A data access layer for interacting with a S3-based storage system. It provides various methods to perform operations such as retrieving files, checking file or directory existence, obtaining file content, uploading files, downloading files, and deleting files or directories within the S3 storage system. This class utilizes the Amazon S3 SDK v2 for S3 client operations and requires AWS credentials and a S3 configuration to be initialized.
Autor:
Denys Chaykovskiy
  • Konstruktordetails

  • Methodendetails

    • getConfiguration

      public S3Configuration getConfiguration()
      Gets the S3 configuration used by this S3DAL instance.
      Gibt zurück:
      the S3Configuration object
    • initS3ClientV1

      public void initS3ClientV1() throws IOException
      Initializes the S3 v1 client.
      Löst aus:
      IOException - if an I/O exception occurs
    • initS3ClientV2

      public void initS3ClientV2() throws IOException
      Initializes the S3 v2 client.
      Löst aus:
      IOException - if an I/O exception occurs
    • getFiles

      public List<String> getFiles() throws IOException
      Retrieves a list of all files in the current bucket.
      Gibt zurück:
      a list of all file paths
      Löst aus:
      IOException - if an I/O exception occurs
    • getFiles

      public List<String> getFiles(String folder) throws IOException
      Retrieves a list of files that match the specified folder (prefix).
      Parameter:
      folder - the folder (prefix) to match
      Gibt zurück:
      a list of file paths that match the folder
      Löst aus:
      IOException - if an I/O exception occurs
    • fileExists

      public boolean fileExists(String filePath) throws IOException
      Checks if a file exists in the storage system.
      Parameter:
      filePath - the file path
      Gibt zurück:
      true if the file exists, false otherwise
      Löst aus:
      IOException - if an I/O exception occurs
    • isFile

      public boolean isFile(String path)
      Checks if the specified path represents a file (not a directory).
      Parameter:
      path - the path to check
      Gibt zurück:
      true if the path represents a file, false otherwise
    • getFileName

      public String getFileName(String path)
      Gets the name of the file from the specified path.
      Parameter:
      path - the file path
      Gibt zurück:
      the name of the file
    • getFileSize

      public long getFileSize(String filePath) throws IOException
      Retrieves the size of the file specified by the file path.
      Parameter:
      filePath - the file path
      Gibt zurück:
      the size of the file in bytes
      Löst aus:
      IOException - if an I/O exception occurs
    • getFileContent

      public String getFileContent(String filePath) throws IOException
      Retrieves the content of the file specified by the file path.
      Parameter:
      filePath - the file path
      Gibt zurück:
      the content of the file
      Löst aus:
      IOException - if an I/O exception occurs
    • uploadFile

      public String uploadFile(String sourceFile, String targetFileOrDir) throws IOException
      Uploads a file to the storage system.
      Parameter:
      sourceFile - the source file to upload
      targetFileOrDir - the target file or directory in the storage system
      Gibt zurück:
      the uploaded file path in the storage system
      Löst aus:
      IOException - if an I/O exception occurs if the file cannot be uploaded
    • upload

      public List<String> upload(String sourceFileOrDir, String targetFileOrDir) throws IOException
      Uploads a file or directory to the storage system.
      Parameter:
      sourceFileOrDir - the source file or directory to upload
      targetFileOrDir - the target file or directory in the storage system
      Gibt zurück:
      a list of uploaded file paths in the storage system
      Löst aus:
      IOException - if an I/O exception occurs if the file or directory cannot be uploaded
    • upload

      public List<String> upload(String sourceFileOrDir) throws IOException
      Uploads a file or directory to the storage system.
      Parameter:
      sourceFileOrDir - the source file or directory to upload
      Gibt zurück:
      a list of uploaded file or directory paths in the storage system
      Löst aus:
      IOException - if an I/O exception occurs if the file or directory cannot be uploaded
    • downloadFile

      public String downloadFile(String sourceFile, String targetFileOrDir) throws IOException
      Downloads a file from the storage system.
      Parameter:
      sourceFile - the source file in the storage system to download
      targetFileOrDir - the target file or directory to download to
      Gibt zurück:
      the downloaded file path
      Löst aus:
      IOException - if an I/O exception occurs if the file cannot be downloaded
    • download

      public List<String> download(String sourceFileOrDir, String targetFileOrDir) throws IOException
      Downloads a file or directory from the storage system.
      Parameter:
      sourceFileOrDir - the source file or directory in the storage system to download
      targetFileOrDir - the target file or directory to download to
      Gibt zurück:
      a list of downloaded file or directory paths
      Löst aus:
      IOException - if an I/O exception occurs if the file or directory cannot be downloaded
    • download

      public List<String> download(String prefixFileOrDir) throws IOException
      Downloads a file or directory with a prefix match from the storage system.
      Parameter:
      prefixFileOrDir - the prefix file or directory to match
      Gibt zurück:
      a list of downloaded file paths
      Löst aus:
      IOException - if an I/O exception occurs if the file or directory cannot be downloaded
    • delete

      public List<String> delete(String fileOrDir) throws IOException
      Deletes a file or directory.
      Parameter:
      fileOrDir - the file or directory to delete
      Gibt zurück:
      a list of deleted file paths
      Löst aus:
      IOException - if an I/O exception occurs
    • deleteFile

      public String deleteFile(String filepath) throws IOException
      Deletes a file.
      Parameter:
      filepath - the file path
      Gibt zurück:
      the deleted file path
      Löst aus:
      IOException - if an I/O exception occurs
    • deleteFiles

      public List<String> deleteFiles() throws IOException
      Deletes files.
      Gibt zurück:
      a list of deleted file paths
      Löst aus:
      IOException - if an I/O exception occurs
    • deleteFiles

      public List<String> deleteFiles(List<String> toDeleteList)
      Deletes files.
      Parameter:
      toDeleteList - a list of file or directory paths to delete
      Gibt zurück:
      a list of deleted file paths
    • setBucket

      public void setBucket(String bucket) throws IOException
      Sets the bucket to use for operations.
      Parameter:
      bucket - the bucket name
      Löst aus:
      IOException - if an I/O exception occurs
    • getBucket

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

      public List<String> getBuckets() throws IOException
      Gets the list of available buckets.
      Gibt zurück:
      a list of bucket names
      Löst aus:
      IOException - if an I/O exception occurs
    • bucketExists

      public boolean bucketExists(String bucketName) throws IOException
      Checks if a bucket exists in the storage system.
      Parameter:
      bucketName - the bucket name
      Gibt zurück:
      true if the bucket exists, false otherwise
      Löst aus:
      IOException - if an I/O exception occurs
    • deleteBucket

      public void deleteBucket(String bucketName) throws IOException
      Deletes a bucket from the storage system.
      Parameter:
      bucketName - the bucket name
      Löst aus:
      IOException - if an I/O exception occurs
    • getInputStream

      public InputStream getInputStream(String relativePath) throws IOException
      Gets an input stream from a file in the storage system.
      Parameter:
      relativePath - the relative file path
      Gibt zurück:
      an InputStream object for reading the file content
      Löst aus:
      IOException - if an I/O exception occurs