Klasse StorageProvider

java.lang.Object
de.dlr.proseo.storagemgr.StorageProvider

@Component public class StorageProvider extends Object
A central manager for different types of storage in the application. It handles the creation, retrieval, and management of storage instances, provides file-related operations and paths, and offers various utility methods related to storage management. This class acts as a singleton and manages the storage configuration, source paths, and storage operations. Author: Denys Chaykovskiy
  • Felddetails

    • basePaths

      List<String> basePaths
      Base Paths are used to get relative path from absolute path
  • Konstruktordetails

    • StorageProvider

      public StorageProvider()
      Simple default constructor
  • Methodendetails

    • getInstance

      public static StorageProvider getInstance()
      Returns the instance of the storage provider (singleton).
      Gibt zurück:
      the storage provider singleton instance
    • loadDefaultPaths

      public void loadDefaultPaths()
      Load default source, storage, and cache paths
    • setSourcePath

      public void setSourcePath(String sourcePath)
      Sets the source path.
      Parameter:
      sourcePath - the source path to set
    • setStoragePath

      public void setStoragePath(String storagePath)
      Sets the storage path.
      Parameter:
      storagePath - the storage path to set
    • setCachePath

      public void setCachePath(String cachePath)
      Sets the cache path.
      Parameter:
      cachePath - the cache path to set
    • getSourcePath

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

      public String getStoragePath()
      Gets the storage path.
      Gibt zurück:
      the storage path
    • getCachePath

      public String getCachePath()
      Gets the cache path.
      Gibt zurück:
      the cache path
    • getStorage

      public Storage getStorage()
      Gets the current storage instance.
      Gibt zurück:
      the current storage instance
    • getStorage

      public Storage getStorage(StorageType storageType) throws IOException
      Gets the desired storage instance based on the specified storage type.
      Parameter:
      storageType - the storage type
      Gibt zurück:
      the storage instance
      Löst aus:
      IOException - if an error occurs during storage creation
    • getStorage

      public Storage getStorage(String absolutePath) throws IOException
      Gets the storage instance based on the specified absolute path.
      Parameter:
      absolutePath - the absolute path
      Gibt zurück:
      the storage instance
      Löst aus:
      IOException - if an error occurs during storage retrieval
    • setStorage

      public Storage setStorage(StorageType storageType) throws IOException
      Sets the default storage type and creates the corresponding storage instance.
      Parameter:
      storageType - the storage type to set
      Gibt zurück:
      the created storage instance
      Löst aus:
      IOException - if an error occurs during storage creation
    • getBasePaths

      public List<String> getBasePaths()
      Gets the list of base paths.
      Gibt zurück:
      the list of base paths
    • getCacheFileSize

      public long getCacheFileSize(String relativePath) throws IOException
      Gets the file size of the cache file specified by the relative path.
      Parameter:
      relativePath - the relative path of the cache file
      Gibt zurück:
      the file size in bytes
      Löst aus:
      IOException - if an error occurs while getting the file size
    • getSourceFileSize

      public long getSourceFileSize(String relativePath) throws IOException
      Gets the file size of the source file specified by the relative path.
      Parameter:
      relativePath - the relative path of the source file
      Gibt zurück:
      the file size in bytes
      Löst aus:
      IOException - if an error occurs while getting the file size
    • getPosixFileSize

      public long getPosixFileSize(String absolutePath) throws IOException
      Gets the file size of the posix file specified by the absolute path.
      Parameter:
      absolutePath - the absolute path of the posix file
      Gibt zurück:
      the file size in bytes
      Löst aus:
      IOException - if an error occurs while getting the file size
    • getCacheFile

      public StorageFile getCacheFile(String relativePath)
      Gets the cache file as a StorageFile from the relative path. The path can be virtual.
      Parameter:
      relativePath - the relative path of the cache file
      Gibt zurück:
      the StorageFile representing the cache file
    • getSourceFile

      public StorageFile getSourceFile(String relativePath)
      Gets the source file as a StorageFile from the relative path. The path can be virtual.
      Parameter:
      relativePath - the relative path of the source file
      Gibt zurück:
      the StorageFile representing the source file
    • getPosixFile

      public StorageFile getPosixFile(String basePath, String relativePath)
      Gets the posix file as a StorageFile from the relative path. The path can be virtual.
      Parameter:
      basePath - the base path of the posix storage
      relativePath - the relative path of the file
      Gibt zurück:
      the StorageFile representing the posix file
    • getStorageFile

      public StorageFile getStorageFile(String relativePath)
      Gets the storage file as a StorageFile from the relative path. The path can be virtual.
      Parameter:
      relativePath - the relative path of the file
      Gibt zurück:
      the StorageFile representing the storage file
    • getFileSize

      public Long getFileSize(StorageFile storageFile) throws IOException
      Gets the file size of the storage file specified by the StorageFile instance.
      Parameter:
      storageFile - the StorageFile instance
      Gibt zurück:
      the file size in bytes
      Löst aus:
      IOException - if an error occurs while getting the file size
    • getInputStream

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

      public StorageFile getAbsoluteFile(String absolutePath)
      Gets a file as a StorageFile from the absolute path. The path to the file can be virtual.
      Parameter:
      absolutePath - the absolute path to the file
      Gibt zurück:
      the StorageFile representing the file
    • getAbsoluteSourcePath

      public String getAbsoluteSourcePath(String relativePath)
      Gets the absolute source path from the relative path.
      Parameter:
      relativePath - the relative path to the file
      Gibt zurück:
      the absolute source path from the relative path
    • getAbsoluteCachePath

      public String getAbsoluteCachePath(String relativePath)
      Gets the absolute cache path from the relative path.
      Parameter:
      relativePath - the relative path to the file
      Gibt zurück:
      the absolute cache path from the relative path
    • getAbsolutePosixStoragePath

      public String getAbsolutePosixStoragePath(String relativePath)
      Gets the absolute posix storage path from the relative path.
      Parameter:
      relativePath - the relative path
      Gibt zurück:
      the absolute posix storage path from the relative path
    • getRelativePath

      public String getRelativePath(String absolutePath) throws IOException
      Gets the relative path from the absolute path using the base path list.
      Parameter:
      absolutePath - the absolute path
      Gibt zurück:
      the relative path
      Löst aus:
      IOException - if an error occurs while getting the relative path
    • createStorageFile

      public StorageFile createStorageFile(String relativePath, String content) throws IOException
      Creates a physical file in the storage based on the relative path and content.
      Parameter:
      relativePath - the relative path to the file
      content - the content of the file
      Gibt zurück:
      the StorageFile representing the physically created file
      Löst aus:
      IOException - if an error occurs while creating the storage file
    • getPosixConfigurationFromFile

      public PosixConfiguration getPosixConfigurationFromFile()
      Gets the POSIX configuration from the file.
      Gibt zurück:
      the POSIX configuration
    • getS3ConfigurationFromFile

      public S3Configuration getS3ConfigurationFromFile()
      Gets the S3 configuration from the file.
      Gibt zurück:
      the S3 configuration
    • copyAbsoluteFilesToCache

      public List<String> copyAbsoluteFilesToCache(String sourceFileOrDir, Long productId) throws IOException
      Parameter:
      sourceFileOrDir -
      Gibt zurück:
      Löst aus:
      IOException