Class CmsFsStorage
- All Implemented Interfaces:
AutoCloseable,I_CmsEnumerableStorage,I_CmsStorage,I_CmsStorageDelivery
This implementation stores binary content as files in the local file system. It uses a 3-level directory structure based on the content hash to avoid having too many files in a single directory.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opencms.db.storage.I_CmsEnumerableStorage
I_CmsEnumerableStorage.I_CmsContentHashVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe type name of the storage implementation. -
Constructor Summary
ConstructorsConstructorDescriptionCmsFsStorage(String name, String basePath) Creates a new file system storage. -
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.voidstreamRangeTo(CmsDbContext dbc, String hash, long start, long length, OutputStream out) Streams a byte range to the given output stream.voidstreamTo(CmsDbContext dbc, String hash, OutputStream out) Streams the content to the given output stream.booleanReturns if range delivery is supported.voidValidates that the storage backend is available for read and write operations.voidVisits all content hashes stored by this backend.Methods inherited from class org.opencms.db.storage.A_CmsStorage
getHashedPath, validateHashMethods 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
-
STORAGE_TYPE
The type name of the storage implementation.- See Also:
-
-
Constructor Details
-
CmsFsStorage
Creates a new file system storage.- Parameters:
name- the configured backend id used as storage identifierbasePath- the base path for the storage repository
-
-
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:
-
streamRangeTo
public void streamRangeTo(CmsDbContext dbc, String hash, long start, long length, OutputStream out) throws Exception Description copied from interface:I_CmsStorageDeliveryStreams a byte range to the given output stream.- Specified by:
streamRangeToin interfaceI_CmsStorageDelivery- Parameters:
dbc- the database contexthash- the SHA-512 content hashstart- the first byte to streamlength- the number of bytes to streamout- the output stream to write to- Throws:
Exception- if streaming fails- See Also:
-
streamTo
Description copied from interface:I_CmsStorageDeliveryStreams the content to the given output stream.- Specified by:
streamToin interfaceI_CmsStorageDelivery- Parameters:
dbc- the database contexthash- the SHA-512 content hashout- the output stream to write to- Throws:
Exception- if streaming fails- See Also:
-
supportsRangeDelivery
Description copied from interface:I_CmsStorageDeliveryReturns if range delivery is supported.- Specified by:
supportsRangeDeliveryin interfaceI_CmsStorageDelivery- Returns:
trueif byte range delivery is supported- 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:
-
visitContentHashes
public void visitContentHashes(CmsDbContext dbc, I_CmsEnumerableStorage.I_CmsContentHashVisitor visitor) throws Exception Description copied from interface:I_CmsEnumerableStorageVisits all content hashes stored by this backend.- Specified by:
visitContentHashesin interfaceI_CmsEnumerableStorage- Parameters:
dbc- the database contextvisitor- the content hash visitor- Throws:
Exception- if enumeration fails- See Also:
-