Class CmsDbStorage
- All Implemented Interfaces:
AutoCloseable,I_CmsDbStorage,I_CmsStorage
- Direct Known Subclasses:
CmsDbStorage,CmsDbStorage,CmsDbStorage,CmsDbStorage,CmsDbStorage,CmsDbStorage,CmsDbStorage
This implementation stores binary content in a specialized table (CMS_STORAGE), using a unique hash for deduplication. It ensures that identical files are only stored once physically.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CmsSqlManagerThe SQL manager to execute database queries.Fields inherited from interface org.opencms.db.storage.I_CmsDbStorage
STORAGE_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteContent(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.voidloadContentFrom(CmsDbContext dbc, String hash, I_CmsFileContentStreamHandler handler) Loads the actual binary content and passes it to the given input stream handler.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opencms.db.storage.I_CmsStorage
close
-
Field Details
-
m_sqlManager
The SQL manager to execute database queries.
-
-
Constructor Details
-
CmsDbStorage
Public constructor.- Parameters:
sqlManager- the SQL manager to use
-
-
Method Details
-
deleteContent
Description copied from interface:I_CmsStorageDeletes the content from the storage if applicable.- Specified by:
deleteContentin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hash- Throws:
Exception- if the deletion in the external storage fails- See Also:
-
getStorageIdentifier
Description copied from interface:I_CmsStorageReturns 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.- Specified by:
getStorageIdentifierin interfaceI_CmsStorage- Returns:
- the stable storage identifier
- See Also:
-
loadContent
Description copied from interface:I_CmsStorageLoads the actual binary content.- Specified by:
loadContentin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hash- Returns:
- the actual binary file content
- Throws:
Exception- if the content cannot be retrieved- See Also:
-
loadContentFrom
public void loadContentFrom(CmsDbContext dbc, String hash, I_CmsFileContentStreamHandler handler) throws Exception Description copied from interface:I_CmsStorageLoads 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
I_CmsStorage.loadContent(CmsDbContext, String).- Specified by:
loadContentFromin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hashhandler- the stream handler- Throws:
Exception- if the content cannot be retrieved or handled- See Also:
-
loadContentTo
Description copied from interface:I_CmsStorageLoads the actual binary content into the given output stream.This default implementation keeps custom storage implementations source compatible by falling back to
I_CmsStorage.loadContent(CmsDbContext, String).- Specified by:
loadContentToin interfaceI_CmsStorage- 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- See Also:
-
storeContent
Description copied from interface:I_CmsStorageStores the given content.- Specified by:
storeContentin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hashcontent- the actual binary data to store- Throws:
Exception- if the storage operation fails- See Also:
-
validateAvailable
Description copied from interface:I_CmsStorageValidates 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.
- Specified by:
validateAvailablein interfaceI_CmsStorage- Parameters:
dbc- the database context- Throws:
Exception- if the storage backend is not available- See Also:
-