Interface I_CmsStorage

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
I_CmsDbStorage, I_CmsEnumerableStorage
All Known Implementing Classes:
CmsDbStorage, CmsDbStorage, CmsDbStorage, CmsDbStorage, CmsDbStorage, CmsDbStorage, CmsDbStorage, CmsDbStorage, CmsFsStorage, CmsS3Storage

public interface I_CmsStorage extends AutoCloseable
Storage backend interface for the OpenCms deduplicating media storage engine (DMSE).

This interface abstracts the physical storage of binary resource content in database, file system or S3-compatible backends. Content is addressed by its SHA-512 hash.

See Also:
  • Method Details

    • close

      default void close() throws Exception
      Closes this storage backend and releases associated resources.

      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception - if closing the storage backend fails
    • deleteContent

      void deleteContent(CmsDbContext dbc, String hash) throws Exception
      Deletes the content from the storage if applicable.

      Parameters:
      dbc - the database context
      hash - the SHA-512 content hash
      Throws:
      Exception - if the deletion in the external storage fails
    • getStorageIdentifier

      Returns the stable storage identifier stored in the VFS content tables.

      The identifier is the configured backend id, for example media or archive. The database storage uses the reserved backend id db. The identifier must not depend on mutable connection details such as paths, endpoints, or bucket names.

      Returns:
      the stable storage identifier
    • loadContent

      byte[] loadContent(CmsDbContext dbc, String hash) throws Exception
      Loads the actual binary content.

      Parameters:
      dbc - the database context
      hash - the SHA-512 content hash
      Returns:
      the actual binary file content
      Throws:
      Exception - if the content cannot be retrieved
    • loadContentFrom

      default void loadContentFrom(CmsDbContext dbc, String hash, I_CmsFileContentStreamHandler handler) throws Exception
      Loads the actual binary content and passes it to the given input stream handler.

      This default implementation keeps custom storage implementations source compatible by falling back to loadContent(CmsDbContext, String).

      Parameters:
      dbc - the database context
      hash - the SHA-512 content hash
      handler - the stream handler
      Throws:
      Exception - if the content cannot be retrieved or handled
    • loadContentTo

      default void loadContentTo(CmsDbContext dbc, String hash, OutputStream out) throws Exception
      Loads the actual binary content into the given output stream.

      This default implementation keeps custom storage implementations source compatible by falling back to loadContent(CmsDbContext, String).

      Parameters:
      dbc - the database context
      hash - the SHA-512 content hash
      out - the output stream to write to
      Throws:
      Exception - if the content cannot be retrieved or written
    • storeContent

      void storeContent(CmsDbContext dbc, String hash, byte[] content) throws Exception
      Stores the given content.

      Parameters:
      dbc - the database context
      hash - the SHA-512 content hash
      content - the actual binary data to store
      Throws:
      Exception - if the storage operation fails
    • validateAvailable

      Validates that the storage backend is available for read and write operations.

      This method is called during startup for configured storage backends. Implementations should perform a lightweight roundtrip which verifies the required prerequisites for storing content.

      Parameters:
      dbc - the database context
      Throws:
      Exception - if the storage backend is not available