Interface ContentStore
readers and
writers.
Implementations of this interface should be soley responsible for
providing persistence and retrieval of the content against a
content URL.
Content URLs must consist of a prefix or protocol followed by an
implementation-specific identifier. See
TimeBasedFileContentUrlProvider and
VolumeAwareContentUrlProvider implementations of
FileContentUrlProvider
For example, default content URL format
for file stores is store://year/month/day/hour/minute/GUID.bin
- store://: prefix identifying an Alfresco content stores regardless of the persistence mechanism.
- year: year
- month: 1-based month of the year
- day: 1-based day of the month
- hour: 0-based hour of the day
- minute: 0-based minute of the hour
- GUID: A unique identifier
Where the store cannot handle a particular content URL request, the
UnsupportedContentUrlException must be generated. This will allow
various implementations to provide fallback code to other stores where
possible.
Where a store cannot serve a particular request because the functionality
is just not available, the UnsupportedOperationException should
be thrown. Once again, there may be fallback handling provided for these
situations.
- Since:
- 1.0
- Author:
- Derek Hulley
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ContentContextAn empty content context used to retrieve completely new content.static final StringThe delimiter that must be found in all URLS, i.e :// -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeletes the content at the given URL.booleanCheck for the existence of content in the store.Get the accessor with which to read from the content at the given URL.Get the location where the store is rooted.longCalculates the remaning free space in the underlying store.longCalculates the total storage space of the underlying store.getStorageProperties(String contentUrl) Gets a key-value (String-String) collection of storage headers/properties with their respective values.getWriter(ContentContext context) Get an accessor with which to write content to a location within the store.default booleanChecks if the store supports the retrieving of direct access URLs.default booleanisContentDirectUrlEnabled(String contentUrl) Checks if the store supports the retrieving of a direct access URL for the given node.booleanisContentUrlSupported(String contentUrl) Check if the content URL format is supported by the store.booleanCheck if the store supports write requests.default DirectAccessUrlrequestContentDirectUrl(String contentUrl, boolean attachment, String fileName) Deprecated.default DirectAccessUrlrequestContentDirectUrl(String contentUrl, boolean attachment, String fileName, Long validFor) Deprecated.default DirectAccessUrlrequestContentDirectUrl(String contentUrl, boolean attachment, String fileName, String mimetype) Gets a presigned URL to directly access the content.default DirectAccessUrlrequestContentDirectUrl(String contentUrl, boolean attachment, String fileName, String mimetype, Long validFor) Gets a presigned URL to directly access the content.default booleanrequestRestoreContentFromArchive(String contentUrl, Map<String, Serializable> restoreParams) Submit a request to restore content from archive (offline) state.default booleanrequestSendContentToArchive(String contentUrl, Map<String, Serializable> archiveParams) Submit a request to send content to archive (offline) state.
-
Field Details
-
NEW_CONTENT_CONTEXT
An empty content context used to retrieve completely new content.- See Also:
-
PROTOCOL_DELIMITER
The delimiter that must be found in all URLS, i.e ://- See Also:
-
-
Method Details
-
isContentUrlSupported
Check if the content URL format is supported by the store.- Parameters:
contentUrl- the content URL to check- Returns:
- Returns true if none of the other methods on the store
will throw an
UnsupportedContentUrlExceptionwhen given this URL. - Since:
- 2.1
-
isWriteSupported
boolean isWriteSupported()Check if the store supports write requests.- Returns:
- Return true is the store supports write operations
- Since:
- 2.1
-
getSpaceFree
long getSpaceFree()Calculates the remaning free space in the underlying store.NOTE: For efficiency, some implementations may provide a guess.
Implementations should focus on calculating a size value quickly, rather than accurately.
- Returns:
- Returns the total, possibly approximate, free space (in bytes) available to the store or -1 if no size data is available.
- Since:
- 3.3.3
-
getSpaceTotal
long getSpaceTotal()Calculates the total storage space of the underlying store.NOTE: For efficiency, some implementations may provide a guess.
Implementations should focus on calculating a size value quickly, rather than accurately.
- Returns:
- Returns the total, possibly approximate, size (in bytes) of the underlying store or -1 if no size data is available.
- Since:
- 3.3.3
-
getRootLocation
String getRootLocation()Get the location where the store is rooted. The format of the returned value will depend on the specific implementation of the store.- Returns:
- Returns the store's root location or . if no information is available
-
exists
Check for the existence of content in the store.The implementation of this may be more efficient than first getting a reader to
check for existence, although that check should also be performed.- Parameters:
contentUrl- the path to the content- Returns:
- Returns true if the content exists, otherwise false if the content doesn't exist or if the URL is not applicable to this store.
- Throws:
org.alfresco.repo.content.UnsupportedContentUrlException- if the content URL supplied is not supported by the storeContentIOException- if an IO error occurs- See Also:
-
getReader
Get the accessor with which to read from the content at the given URL. The reader is stateful and can only be used once.- Parameters:
contentUrl- the path to where the content is located- Returns:
- Returns a read-only content accessor for the given URL. There may be no content at the given URL, but the reader must still be returned.
- Throws:
org.alfresco.repo.content.UnsupportedContentUrlException- if the content URL supplied is not supported by the storeContentIOException- if an IO error occurs- See Also:
-
exists(String)ContentReader.exists()org.alfresco.repo.content.EmptyContentReader
-
getWriter
Get an accessor with which to write content to a location within the store. The writer is stateful and can only be used once. The location may be specified but must, in that case, be a valid and unused URL.The store will ensure that the
new content URLwill be valid for all subsequent read attempts.By supplying a reader to existing content, the store implementation may enable random access. The store implementation can enable this by copying the existing content into the new location before supplying a writer onto the new content.
- Parameters:
context- the context of content.- Returns:
- Returns a write-only content accessor
- Throws:
UnsupportedOperationException- if the store is unable to provide the informationUnsupportedContentUrlException- if the content URL supplied is not supported by the storeContentExistsException- if the content URL is already in useContentIOException- if an IO error occurs- See Also:
-
delete
Deletes the content at the given URL.A delete cannot be forced since it is much better to have the file remain longer than desired rather than deleted prematurely.
- Parameters:
contentUrl- the URL of the content to delete- Returns:
- Returns true if the content was deleted (either by this or another operation), otherwise false. If the content no longer exists, then true is returned.
- Throws:
UnsupportedOperationException- if the store is unable to perform the actionUnsupportedContentUrlException- if the content URL supplied is not supported by the storeContentIOException- if an error occurs if an IO error occurs
-
isContentDirectUrlEnabled
default boolean isContentDirectUrlEnabled()Checks if the store supports the retrieving of direct access URLs.- Returns:
trueif direct access URLs retrieving is supported,falseotherwise
-
isContentDirectUrlEnabled
Checks if the store supports the retrieving of a direct access URL for the given node.- Parameters:
contentUrl- theURLof the content for which to request a direct accessURL- Returns:
trueif direct access URLs retrieving is supported for the node,falseotherwise
-
requestContentDirectUrl
@Deprecated default DirectAccessUrl requestContentDirectUrl(String contentUrl, boolean attachment, String fileName) Deprecated.Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
contentUrl- A content storeURLattachment-trueif an attachment URL is requested,falsefor an embeddedURL.fileName- File name of the content- Returns:
- A direct access
URLobject for the content - Throws:
UnsupportedOperationException- if the store is unable to provide the information
-
requestContentDirectUrl
default DirectAccessUrl requestContentDirectUrl(String contentUrl, boolean attachment, String fileName, String mimetype) Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
contentUrl- A content storeURLattachment-trueif an attachment URL is requested,falsefor an embeddedURL.fileName- File name of the content- Returns:
- A direct access
URLobject for the content - Throws:
UnsupportedOperationException- if the store is unable to provide the information
-
requestContentDirectUrl
@Deprecated default DirectAccessUrl requestContentDirectUrl(String contentUrl, boolean attachment, String fileName, Long validFor) Deprecated.Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
contentUrl- A content storeURLattachment-trueif an attachment URL is requested,falsefor an embeddedURL.fileName- File name of the contentvalidFor- The time at which the direct accessURLwill expire.- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information
-
requestContentDirectUrl
default DirectAccessUrl requestContentDirectUrl(String contentUrl, boolean attachment, String fileName, String mimetype, Long validFor) Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.- Parameters:
contentUrl- A content storeURLattachment-trueif an attachment URL is requested,falsefor an embeddedURL.fileName- File name of the contentmimetype- Mimetype of the contentvalidFor- The time at which the direct accessURLwill expire.- Returns:
- A direct access
URLobject for the content. - Throws:
UnsupportedOperationException- if the store is unable to provide the information
-
getStorageProperties
Gets a key-value (String-String) collection of storage headers/properties with their respective values. A particular Cloud Connector will fill in that data with Cloud Storage Provider generic data. Map may be also filled in with entries consisting of pre-defined Alfresco keys ofObjectStoragePropsand their values. If empty Map is returned - no connector is present or connector is not supporting retrieval of the properties or cannot determine the properties.- Parameters:
contentUrl- the URL of the content for which the storage properties are to be retrieved.- Returns:
- Returns a key-value (String-String) collection of storage headers/properties with their respective values.
-
requestSendContentToArchive
default boolean requestSendContentToArchive(String contentUrl, Map<String, Serializable> archiveParams) Submit a request to send content to archive (offline) state. If no connector is present or connector is not supporting sending to archive, thenUnsupportedOperationExceptionwill be returned. Specific connector will decide which storage class/tier will be set for content.- Parameters:
contentUrl- the URL of the content which is to be archived.archiveParams- a map of String-Serializable parameters defining Storage Provider specific request parameters (can be empty).- Returns:
- true when request successful, false when unsuccessful.
- Throws:
UnsupportedOperationException- when store is unable to handle request.
-
requestRestoreContentFromArchive
default boolean requestRestoreContentFromArchive(String contentUrl, Map<String, Serializable> restoreParams) Submit a request to restore content from archive (offline) state. If no connector is present or connector is not supporting restoring fom archive, thenUnsupportedOperationExceptionwill be returned. One of input parameters of this method is a map (String-Serializable) of Storage Provider specific input needed to perform proper restore. Keys of this map should be restricted toContentRestoreParamsenumeration. For AWS S3 map can indicating expiry days, Glacier restore tier. For Azure Blob map can indicate rehydrate priority.- Parameters:
contentUrl- the URL of the content which is to be archived.restoreParams- a map of String-Serializable parameters defining Storage Provider specific request parameters (can be empty).- Returns:
- true when request successful, false when unsuccessful.
- Throws:
UnsupportedOperationException- when store is unable to handle request.
-