Klasse PosixStorage

java.lang.Object
de.dlr.proseo.storagemgr.posix.PosixStorage
Alle implementierten Schnittstellen:
Storage

public class PosixStorage extends Object implements 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.
Autor:
Denys Chaykovskiy
  • Konstruktordetails

    • PosixStorage

      public PosixStorage(PosixConfiguration cfg)
      No bucket constructor initializing the storage with a basePath and sourcePath. It creates the necessary directories if they don't exist.
      Parameter:
      cfg - POSIX configuration
  • 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 (file system prefix + bucket + base path). In this no-bucket POSIX version, it returns the base path.
      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)
      Sets the bucket.
      Angegeben von:
      setBucket in Schnittstelle Storage
      Parameter:
      bucket - the bucket to set
    • getBucket

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

      public List<String> getBuckets()
      Gets the buckets from the storage.
      Angegeben von:
      getBuckets in Schnittstelle Storage
      Gibt zurück:
      the list of buckets (one bucket)
    • bucketExists

      public boolean bucketExists(String bucketName)
      Checks if the bucket exists. In the one-bucket concept, it compares with the current bucket.
      Angegeben von:
      bucketExists in Schnittstelle Storage
      Parameter:
      bucketName - the name of the bucket
      Gibt zurück:
      true if the bucket exists
    • deleteBucket

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

      public List<String> getRelativeFiles(String relativePath)
      Gets files from the storage with the given prefix (folder).
      Angegeben von:
      getRelativeFiles in Schnittstelle Storage
      Parameter:
      relativePath - the prefix (folder) for searching in the storage
      Gibt zurück:
      the list of files with the given prefix
    • getRelativeFiles

      public List<String> getRelativeFiles()
      Gets all files from the storage.
      Angegeben von:
      getRelativeFiles in Schnittstelle Storage
      Gibt zurück:
      the list of all files from the storage
    • getAbsoluteFiles

      public List<String> getAbsoluteFiles(String relativePath)
      Gets files (absolute paths) from the storage with the given prefix (folder).
      Angegeben von:
      getAbsoluteFiles in Schnittstelle Storage
      Parameter:
      relativePath - the prefix (relative path) for searching in the storage
      Gibt zurück:
      the list of files with the given prefix
    • getAbsoluteFiles

      public List<String> getAbsoluteFiles()
      Gets all files (absolute paths) from the storage.
      Angegeben von:
      getAbsoluteFiles in Schnittstelle Storage
      Gibt zurück:
      the list of all files from the storage
    • getRelativePath

      public String getRelativePath(String absolutePath)
      Gets the relative path from the absolute path using the base path list.
      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 using the base path list.
      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 (POSIX: /<storagePath>/<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 (POSIX: /<storagePath>/<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()
      Gets the storage files.
      Angegeben von:
      getStorageFiles in Schnittstelle Storage
      Gibt zurück:
      the list of storage files
    • createStorageFile

      public StorageFile createStorageFile(String relativePath, String content) throws IOException
      Creates a 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)
      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
    • isFile

      public boolean isFile(StorageFile storageFileOrDir)
      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
    • isDirectory

      public boolean isDirectory(StorageFile storageFileOrDir)
      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
    • getFileSize

      public long getFileSize(StorageFile storageFile)
      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
    • 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 the 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 the 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 files to the storage
      Löst aus:
      IOException - if the file or directory cannot be uploaded
    • uploadSourceFile

      public String uploadSourceFile(String relativeSourceFile) throws IOException
      Uploads the source file to the storage.
      Angegeben von:
      uploadSourceFile in Schnittstelle Storage
      Parameter:
      relativeSourceFile - the relative path to the source file
      Gibt zurück:
      the uploaded 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 from the storage.
      Angegeben von:
      download in Schnittstelle Storage
      Parameter:
      sourceFileOrDir - the storage source file or directory to download
      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 the 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 downloaded storage 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 the 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 the 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 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 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 the 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