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
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 Summary
Modifier and TypeMethodDescriptiondefault voidclose()Closes this storage backend and releases associated resources.voiddeleteContent(CmsDbContext dbc, String hash) Deletes the content from the storage if applicable.Returns the stable storage identifier stored in the VFS content tables.byte[]loadContent(CmsDbContext dbc, String hash) Loads the actual binary content.default voidloadContentFrom(CmsDbContext dbc, String hash, I_CmsFileContentStreamHandler handler) Loads the actual binary content and passes it to the given input stream handler.default voidloadContentTo(CmsDbContext dbc, String hash, OutputStream out) Loads the actual binary content into the given output stream.voidstoreContent(CmsDbContext dbc, String hash, byte[] content) Stores the given content.voidValidates that the storage backend is available for read and write operations.
-
Method Details
-
close
Closes this storage backend and releases associated resources.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- if closing the storage backend fails
-
deleteContent
Deletes the content from the storage if applicable.- Parameters:
dbc- the database contexthash- 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
mediaorarchive. The database storage uses the reserved backend iddb. The identifier must not depend on mutable connection details such as paths, endpoints, or bucket names.- Returns:
- the stable storage identifier
-
loadContent
Loads the actual binary content.- Parameters:
dbc- the database contexthash- 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 contexthash- the SHA-512 content hashhandler- the stream handler- Throws:
Exception- if the content cannot be retrieved or handled
-
loadContentTo
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 contexthash- the SHA-512 content hashout- the output stream to write to- Throws:
Exception- if the content cannot be retrieved or written
-
storeContent
Stores the given content.- Parameters:
dbc- the database contexthash- the SHA-512 content hashcontent- 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
-